답안 #777616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
777616 2023-07-09T11:22:10 Z vjudge1 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
311 ms 20736 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;//
}
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 20692 KB Output is correct
2 Correct 192 ms 20652 KB Output is correct
3 Correct 168 ms 20660 KB Output is correct
4 Correct 174 ms 20644 KB Output is correct
5 Correct 172 ms 20656 KB Output is correct
6 Correct 175 ms 20736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 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
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 20692 KB Output is correct
2 Correct 192 ms 20652 KB Output is correct
3 Correct 168 ms 20660 KB Output is correct
4 Correct 174 ms 20644 KB Output is correct
5 Correct 172 ms 20656 KB Output is correct
6 Correct 175 ms 20736 KB Output is correct
7 Correct 1 ms 336 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 199 ms 19140 KB Output is correct
14 Correct 187 ms 19716 KB Output is correct
15 Correct 172 ms 18456 KB Output is correct
16 Correct 206 ms 19036 KB Output is correct
17 Correct 239 ms 6340 KB Output is correct
18 Correct 237 ms 6296 KB Output is correct
19 Correct 247 ms 6272 KB Output is correct
20 Correct 241 ms 6364 KB Output is correct
21 Correct 238 ms 6408 KB Output is correct
22 Correct 241 ms 6356 KB Output is correct
23 Correct 259 ms 6400 KB Output is correct
24 Correct 311 ms 6336 KB Output is correct
25 Correct 187 ms 20700 KB Output is correct
26 Correct 212 ms 20712 KB Output is correct
27 Correct 248 ms 18492 KB Output is correct
28 Correct 263 ms 6784 KB Output is correct
29 Correct 260 ms 18844 KB Output is correct
30 Correct 292 ms 17212 KB Output is correct
31 Correct 262 ms 7080 KB Output is correct
32 Correct 167 ms 19336 KB Output is correct
33 Correct 1 ms 340 KB Output is correct