답안 #1097020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097020 2024-10-05T18:27:51 Z vladilius Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
243 ms 27472 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;
    
    int t, l, r, L, R, out, p, P, f, l1, r1;
    while (q--){
        cin>>t>>l>>r;
        out = (l <= t && t <= r); p = t - 1;
        for (int i = 1; i + 1 <= S; i++){
            L = all[i]; R = all[i + 1] - 1;
            f = (p + L) / k[L]; P = f * k[L];
            l1 = max(l, P - R); r1 = min(r, P - L);
            out += max(0, (r1 - l1 + 1));
            p = (f * k[L] - R) - 1;
        }
        cout<<out<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 24660 KB Output is correct
2 Correct 186 ms 24688 KB Output is correct
3 Correct 155 ms 24660 KB Output is correct
4 Correct 159 ms 24660 KB Output is correct
5 Correct 150 ms 24656 KB Output is correct
6 Correct 165 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 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 24660 KB Output is correct
2 Correct 186 ms 24688 KB Output is correct
3 Correct 155 ms 24660 KB Output is correct
4 Correct 159 ms 24660 KB Output is correct
5 Correct 150 ms 24656 KB Output is correct
6 Correct 165 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 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 159 ms 23092 KB Output is correct
14 Correct 159 ms 23632 KB Output is correct
15 Correct 157 ms 22352 KB Output is correct
16 Correct 154 ms 22864 KB Output is correct
17 Correct 217 ms 27216 KB Output is correct
18 Correct 214 ms 27220 KB Output is correct
19 Correct 221 ms 27216 KB Output is correct
20 Correct 237 ms 27220 KB Output is correct
21 Correct 213 ms 27284 KB Output is correct
22 Correct 224 ms 27472 KB Output is correct
23 Correct 227 ms 27088 KB Output is correct
24 Correct 230 ms 27216 KB Output is correct
25 Correct 177 ms 24656 KB Output is correct
26 Correct 174 ms 24656 KB Output is correct
27 Correct 243 ms 26732 KB Output is correct
28 Correct 233 ms 26960 KB Output is correct
29 Correct 230 ms 26708 KB Output is correct
30 Correct 228 ms 26856 KB Output is correct
31 Correct 241 ms 27216 KB Output is correct
32 Correct 165 ms 23120 KB Output is correct
33 Correct 0 ms 344 KB Output is correct