Submission #777613

# Submission time Handle Problem Language Result Execution time Memory
777613 2023-07-09T11:19:58 Z vjudge1 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
290 ms 23340 KB
#include <bits/stdc++.h>
using namespace std;

const int NM = 5e5;

int N, Q, D[NM+5];
int M = 1, L[NM+5], R[NM+5];

int inter(int l, int r, int u, int v){
	return max(0, min(v, r)-max(u, l)+1);
}

int query(int T, int U, int V){
	int res = inter(T-R[1], T, U, V), cur = T-R[1];
	for (int i = 2; i <= M; i++){
		cur = ((cur+L[i]-1)/D[L[i]])*D[L[i]]-R[i];
		res += inter(cur, cur+R[i]-L[i], U, V);
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> Q;
	D[0] = 1;
	for (int i = 1; i <= N; i++){
		cin >> D[i];
		D[i] = (D[i]/D[i-1]+(D[i]%D[i-1] > 0))*D[i-1];
	}
	L[1] = 0;
	for (int i = 1; i <= N; i++)
		if (D[i] > D[i-1]){
			M++;
			R[M-1] = i-1;
			L[M] = i;
		}
	R[M] = N;
	while (Q--){
		int T, U, V;
		cin >> T >> U >> V;
		cout << query(T, U, V) << '\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 171 ms 20684 KB Output is correct
2 Correct 180 ms 20664 KB Output is correct
3 Correct 175 ms 20680 KB Output is correct
4 Correct 166 ms 20692 KB Output is correct
5 Correct 201 ms 20732 KB Output is correct
6 Correct 169 ms 20636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 171 ms 20684 KB Output is correct
2 Correct 180 ms 20664 KB Output is correct
3 Correct 175 ms 20680 KB Output is correct
4 Correct 166 ms 20692 KB Output is correct
5 Correct 201 ms 20732 KB Output is correct
6 Correct 169 ms 20636 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 171 ms 19216 KB Output is correct
14 Correct 180 ms 19724 KB Output is correct
15 Correct 164 ms 18432 KB Output is correct
16 Correct 181 ms 18916 KB Output is correct
17 Correct 264 ms 23200 KB Output is correct
18 Correct 250 ms 23244 KB Output is correct
19 Correct 248 ms 23328 KB Output is correct
20 Correct 244 ms 23176 KB Output is correct
21 Correct 243 ms 23172 KB Output is correct
22 Correct 246 ms 23304 KB Output is correct
23 Correct 272 ms 23228 KB Output is correct
24 Correct 284 ms 23340 KB Output is correct
25 Correct 177 ms 20620 KB Output is correct
26 Correct 173 ms 20664 KB Output is correct
27 Correct 250 ms 22800 KB Output is correct
28 Correct 262 ms 23120 KB Output is correct
29 Correct 290 ms 22708 KB Output is correct
30 Correct 258 ms 22832 KB Output is correct
31 Correct 259 ms 22984 KB Output is correct
32 Correct 235 ms 19248 KB Output is correct
33 Correct 1 ms 340 KB Output is correct