Submission #44370

#TimeUsernameProblemLanguageResultExecution timeMemory
44370RayaBurong25_1Worst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
944 ms9516 KiB
#include <stdio.h> #include <algorithm> int D[500005]; int E[500005]; int T; typedef struct node node; struct node { int i; }; node V[500005]; int comp1(node element, int value) { return (T/E[element.i]*E[element.i] - element.i) < value; } int comp2(int value, node element) { return (T/E[element.i]*E[element.i] - element.i) > value; } int main() { int N, Q; scanf("%d %d", &N, &Q); int i; D[0] = 1; E[0] = 1; for (i = 1; i <= N; i++) { scanf("%d", &D[i]); E[i] = ((D[i] - 1)/E[i - 1] + 1)*E[i - 1]; // printf("E%d\n", E[i]); } for (i = 0; i <= N; i++) V[i].i = N - i; int L, R; int l, r; int j; for (i = 0; i < Q; i++) { scanf("%d %d %d", &T, &L, &R); l = std::lower_bound(&V[0], &V[N + 1], L, comp1) - &V[0]; r = std::upper_bound(&V[0], &V[N + 1], R, comp2) - &V[0]; // for (j = 0; j <= N; j++) // printf("#%d\n", T/E[j]*E[j] - j); // printf("l%d r%d\n", l, r); printf("%d\n", r - l); } }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:37:9: warning: unused variable 'j' [-Wunused-variable]
     int j;
         ^
worst_reporter3.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &N, &Q);
     ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &D[i]);
         ~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &T, &L, &R);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...