Submission #528834

# Submission time Handle Problem Language Result Execution time Memory
528834 2022-02-21T14:41:15 Z LucaDantas Worst Reporter 3 (JOI18_worst_reporter3) C++17
0 / 100
2 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);
	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

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 time Memory Grader output
1 Runtime error 2 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 2 ms 204 KB Output is correct
3 Incorrect 2 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -