Skip to content

Commit

Permalink
add new problem
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmagic2020 committed Nov 17, 2023
1 parent c1b0f19 commit 9380948
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
Binary file added C++/Distinctos Raffle/main
Binary file not shown.
44 changes: 44 additions & 0 deletions C++/Distinctos Raffle/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <cstdio>
#include <iostream>
#include <cstring>

int N, K, numbers[100005];
int cntr[100005];

int answer;
/**
* AIO 2023
* @link https://orac2.info/problem/aio23raffle/
*
* @mrmagic2020
*/
int main(void) {
memset(cntr, 0, sizeof(cntr));

FILE *input_file = fopen("rafflein.txt", "r");
FILE *output_file = fopen("raffleout.txt", "w");

fscanf(input_file, "%d%d", &N, &K);
for (int i = 0; i < N; i++) {
fscanf(input_file, "%d", &numbers[i]);
cntr[numbers[i]]++;
std::cout << "cntr[" << numbers[i] << "] = " << cntr[numbers[i]] << std::endl;
}

int min = -1;
for (int i = 1; i <= K; i++)
if (cntr[i] == 1)
{
min = i;
break;
}

answer = min;

fprintf(output_file, "%d\n", answer);

fclose(input_file);
fclose(output_file);

return 0;
}
2 changes: 2 additions & 0 deletions C++/Distinctos Raffle/rafflein.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
7 8
3 5 5 6 3 5 6
1 change: 1 addition & 0 deletions C++/Distinctos Raffle/raffleout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1
Binary file added C++/Distinctos Raffle/statement.pdf
Binary file not shown.

0 comments on commit 9380948

Please sign in to comment.