Skip to content

GH-13: Solve problem codejam2022d1000000 #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ bazel-genfiles
bazel-out
bazel-testlogs
bazel-*
*.md2
*.md2
test_data
7 changes: 7 additions & 0 deletions collections/codejam-2022/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Qualification Round
</thead>
<tbody>
<tr>
<td>d1000000</td>
<td><a href="https://codingcompetitions.withgoogle.com/codejam/round/0000000000876ff1/0000000000a46471">Link</a></td>
<td>
<a href="../../problems/codejam2022d1000000/src/main/solution.cpp"><code>cpp🐀</code></a>
</td>
</tr>
<tr>
<td>3D Printing</td>
<td><a href="https://codingcompetitions.withgoogle.com/codejam/round/0000000000876ff1/0000000000a4672b">Link</a></td>
<td>
Expand Down
7 changes: 7 additions & 0 deletions problems/codejam2022d1000000/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
solution
output.txt
/test_data/
/tests
test_data
tests
tests/
10 changes: 10 additions & 0 deletions problems/codejam2022d1000000/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# AoC Problem

## Usage

Run program with an example

```
bazel run src/main:solution < data/sample0.in
bazel run src/main:solution < data/test_set_1/ts1_input.txt
```
9 changes: 9 additions & 0 deletions problems/codejam2022d1000000/data/1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
4
4
6 10 12 8
6
5 4 5 4 4 4
10
10 10 7 6 7 4 4 5 7 4
1
10
1 change: 1 addition & 0 deletions problems/codejam2022d1000000/data/1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
9 changes: 9 additions & 0 deletions problems/codejam2022d1000000/data/sample0.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
4
4
6 10 12 8
6
5 4 5 4 4 4
10
10 10 7 6 7 4 4 5 7 4
1
10
4 changes: 4 additions & 0 deletions problems/codejam2022d1000000/data/sample0.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Case #1: 4
Case #2: 5
Case #3: 9
Case #4: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
4
4
6 10 12 8
6
5 4 5 4 4 4
10
10 10 7 6 7 4 4 5 7 4
1
10
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Case #1: 4
Case #2: 5
Case #3: 9
Case #4: 1
7 changes: 7 additions & 0 deletions problems/codejam2022d1000000/src/main/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")

cc_binary(
name = "solution",
srcs = ["solution.cpp"],
visibility = ["//visibility:public"]
)
36 changes: 36 additions & 0 deletions problems/codejam2022d1000000/src/main/solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <algorithm>
#include <cmath>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
int tt;
int n;
cin >> tt;
int max_n;
for (int ti = 0; ti < tt; ti++) {
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
int i = 0, j = 0;
while(i < n && j < n){
if(a[j] >= i+1){
i++;
j++;
} else {
j++;
}
}
cout << "Case #" << ti + 1 << ": " << i << endl;
}
}