Submission #528837

# Submission time Handle Problem Language Result Execution time Memory
528837 2022-02-21T14:47:44 Z LucaDantas Worst Reporter 3 (JOI18_worst_reporter3) C++17
12 / 100
3 ms 460 KB
#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);
	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+q, [](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;
		}
		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

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:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", d+i);
      |   ~~~~~^~~~~~~~~~~
worst_reporter3.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d %d %d", &qr[i].t, &qr[i].l, &qr[i].r), qr[i].id = i;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
4 Correct 3 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -