답안 #1097017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097017 2024-10-05T18:22:14 Z vladilius Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
271 ms 27232 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, q; cin>>n>>q;
    int d[n + 1];
    for (int i = 1; i <= n; i++){
        cin>>d[i];
    }
    int k[n + 1];
    k[0] = 0; k[1] = d[1];
    for (int i = 2; i <= n; i++){
        k[i] = ceil(1.0 * d[i] / k[i - 1]) * k[i - 1];
    }
    
    int all[n + 1], S = 0;
    for (int i = 1; i <= n; i++){
        if (k[i] != k[i - 1]){
            all[++S] = i;
        }
    }
    all[++S] = n + 1;
    
    while (q--){
        int t, l, r, L, R; cin>>t>>l>>r;
        int out = (l <= t && t <= r), p = t - 1;
        for (int i = 1; i + 1 <= S; i++){
            L = all[i]; R = all[i + 1] - 1;
            int f = (p + L) / k[L], l1 = max(l, f * k[L] - R), r1 = min(r, f * k[L] - L);
            out += max(0, (r1 - l1 + 1));
            p = (f * k[L] - R) - 1;
        }
        cout<<out<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 24696 KB Output is correct
2 Correct 151 ms 24656 KB Output is correct
3 Correct 170 ms 24620 KB Output is correct
4 Correct 152 ms 24740 KB Output is correct
5 Correct 157 ms 24660 KB Output is correct
6 Correct 159 ms 24656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 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 344 KB Output is correct
6 Correct 1 ms 424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 158 ms 24696 KB Output is correct
2 Correct 151 ms 24656 KB Output is correct
3 Correct 170 ms 24620 KB Output is correct
4 Correct 152 ms 24740 KB Output is correct
5 Correct 157 ms 24660 KB Output is correct
6 Correct 159 ms 24656 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 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 344 KB Output is correct
12 Correct 1 ms 424 KB Output is correct
13 Correct 163 ms 23120 KB Output is correct
14 Correct 171 ms 23636 KB Output is correct
15 Correct 182 ms 22348 KB Output is correct
16 Correct 156 ms 22868 KB Output is correct
17 Correct 226 ms 27216 KB Output is correct
18 Correct 212 ms 27232 KB Output is correct
19 Correct 221 ms 26960 KB Output is correct
20 Correct 221 ms 27216 KB Output is correct
21 Correct 214 ms 27216 KB Output is correct
22 Correct 212 ms 27212 KB Output is correct
23 Correct 224 ms 27220 KB Output is correct
24 Correct 265 ms 27216 KB Output is correct
25 Correct 156 ms 24448 KB Output is correct
26 Correct 166 ms 24552 KB Output is correct
27 Correct 232 ms 26852 KB Output is correct
28 Correct 236 ms 27088 KB Output is correct
29 Correct 271 ms 26704 KB Output is correct
30 Correct 233 ms 26676 KB Output is correct
31 Correct 228 ms 26964 KB Output is correct
32 Correct 150 ms 23192 KB Output is correct
33 Correct 0 ms 344 KB Output is correct