From ada1469296304a6788cbdfda21555a1357ebab0e Mon Sep 17 00:00:00 2001 From: yenru0 Date: Thu, 11 Jul 2024 02:29:05 +0900 Subject: [PATCH] complete 19592.c and fix compiler prerunner --- run.py | 4 ++-- zeta_C/19592.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 zeta_C/19592.c diff --git a/run.py b/run.py index 17dcc90..05a62ad 100644 --- a/run.py +++ b/run.py @@ -32,14 +32,14 @@ class ProblemRunEnum: dir="./zeta_C", runner="./a.out", prefix="c", - prerunner="gcc -std=c11 {source}", + prerunner="gcc {source} -std=gnu11 -lm -Wall", ) zeta_cpp: ProblemRunType = ProblemRunType( name="zeta_cpp", dir="./zeta_cpp", runner="./a.out", prefix="cpp", - prerunner="g++ -std=c++17 {source}", + prerunner="g++ {source} -std=c++17 -lm -Wall", ) zeta_kotlin: ProblemRunType = ProblemRunType( name="zeta_kotlin", diff --git a/zeta_C/19592.c b/zeta_C/19592.c new file mode 100644 index 0000000..3829698 --- /dev/null +++ b/zeta_C/19592.c @@ -0,0 +1,54 @@ +#include +#include +#include + +int compare(const void *first, const void *second) { + if (*(int *) first < *(int *) second) + return 1; + else if (*(int *) first > *(int *) second) + return -1; + else + return 0; +} + +int main() { + int T; + scanf("%d", &T); + int N, X, Y; + int *V; + for (int i = 0; i < T; i++) { + scanf("%d %d %d", &N, &X, &Y); + V = (int *) calloc(N, sizeof(int)); + for (int j = 0; j < N; j++) { + scanf("%d", &V[j]); + } + int my_speed = V[N - 1]; + qsort(V, N - 1, sizeof(int), compare); + int rival_speed = V[0]; + double rival_time; + if (my_speed > rival_speed) { + printf("%d\n", 0); + free(V); + continue; + } else { + rival_time = (double) X / (double) rival_speed; + } + double Z; + int iZ; + if (rival_time >= 1) { + Z = X - (rival_time - 1) * my_speed; + } else { + Z = rival_speed + 1; + } + + iZ = floor(Z + 1); + if (iZ > Y) { + printf("%d\n", -1); + } else { + printf("%d\n", iZ); + } + free(V); + } + + return 0; +} \ No newline at end of file