답안 #1018242

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018242 2024-07-09T17:05:32 Z ag_1204 Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
529 ms 29508 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define pb push_back

void solve() {
    int n, q; cin >> n >> q;
    int a[n+1], b[n+1];
    b[0] = 1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = (a[i] + b[i - 1] - 1) / b[i - 1] * b[i - 1];
    }
    while (q--) {
        int t, l, r; cin >> t >> l >> r;
        int resr = n + 1, shift = 0;
        int T=t;
        while (t > 0) {
            int i = upper_bound(b,b+n+1,t)-b-1;
            int dist = t - (t % b[i]);
            t -= dist, shift += dist;
            resr = min(resr, n + 1 - i + max(r - (shift - i), -1LL));
        }
        int resl = n + 1;
        shift = 0;
        t=T;
        while (t > 0) {
            int i = upper_bound(b,b+n+1,t)-b-1;
            int dist = t - (t % b[i]);
            t -= dist, shift += dist;
            resl = min(resl, n + 1 - i + max(l-1 - (shift - i), -1LL));
        }
        cout << resr - resl << '\n';
    }
    return;
}
 
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int tt=1; //cin>>tt;
	while(tt--) {
	    solve();
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 26704 KB Output is correct
2 Correct 165 ms 26520 KB Output is correct
3 Correct 172 ms 26620 KB Output is correct
4 Correct 163 ms 26708 KB Output is correct
5 Correct 170 ms 26708 KB Output is correct
6 Correct 173 ms 26736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 26704 KB Output is correct
2 Correct 165 ms 26520 KB Output is correct
3 Correct 172 ms 26620 KB Output is correct
4 Correct 163 ms 26708 KB Output is correct
5 Correct 170 ms 26708 KB Output is correct
6 Correct 173 ms 26736 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 171 ms 25172 KB Output is correct
14 Correct 226 ms 25772 KB Output is correct
15 Correct 157 ms 24444 KB Output is correct
16 Correct 189 ms 24916 KB Output is correct
17 Correct 413 ms 29128 KB Output is correct
18 Correct 476 ms 29296 KB Output is correct
19 Correct 430 ms 29112 KB Output is correct
20 Correct 446 ms 29236 KB Output is correct
21 Correct 404 ms 29264 KB Output is correct
22 Correct 408 ms 29268 KB Output is correct
23 Correct 395 ms 29208 KB Output is correct
24 Correct 409 ms 29508 KB Output is correct
25 Correct 211 ms 26640 KB Output is correct
26 Correct 184 ms 26564 KB Output is correct
27 Correct 449 ms 28860 KB Output is correct
28 Correct 469 ms 29044 KB Output is correct
29 Correct 462 ms 28480 KB Output is correct
30 Correct 529 ms 28752 KB Output is correct
31 Correct 457 ms 29008 KB Output is correct
32 Correct 166 ms 25312 KB Output is correct
33 Correct 0 ms 348 KB Output is correct