Submission #528834

#TimeUsernameProblemLanguageResultExecution timeMemory
528834LucaDantasWorst Reporter 3 (JOI18_worst_reporter3)C++17
0 / 100
2 ms460 KiB
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 1e3+10; struct Query { int l, r, t, id; } qr[maxn]; int d[maxn], pos[maxn], ANS[maxn]; int main() { int n, q; scanf("%d %d", &n, &q); d[0] = 1; for(int i = 1; i <= n; i++) scanf("%d", d+i); for(int i = 0; i < q; i++) scanf("%d %d %d", &qr[i].t, &qr[i].l, &qr[i].r), qr[i].id = i; sort(qr, qr+n, [](Query a, Query b) { return a.t < b.t; }); for(int i = 1; i <= n; i++) pos[i] = -i; int tempo = 0; for(int i = 0; i < q; i++) { while(tempo < qr[i].t) { ++tempo; pos[0]++; for(int j = 1; j <= n; j++) if(pos[j-1] - pos[j] > d[j]) pos[j] = pos[j-1] - 1; else break; } int ans = 0; for(int j = 0; j <= n; j++) { if(pos[j] >= qr[i].l && pos[j] <= qr[i].r) ++ans; // printf("%d ", pos[j]); } // puts(""); ANS[qr[i].id] = ans; } for(int i = 0; i < q; i++) printf("%d\n", ANS[i]); }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:11:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  int n, q; scanf("%d %d", &n, &q);
      |            ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", d+i);
      |   ~~~~~^~~~~~~~~~~
worst_reporter3.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d %d %d", &qr[i].t, &qr[i].l, &qr[i].r), qr[i].id = i;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...