답안 #1097019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097019 2024-10-05T18:27:24 Z vladilius Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
249 ms 27220 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
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 155 ms 24656 KB Output is correct
2 Correct 150 ms 24728 KB Output is correct
3 Correct 155 ms 24984 KB Output is correct
4 Correct 170 ms 24608 KB Output is correct
5 Correct 145 ms 24664 KB Output is correct
6 Correct 147 ms 24660 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 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 24656 KB Output is correct
2 Correct 150 ms 24728 KB Output is correct
3 Correct 155 ms 24984 KB Output is correct
4 Correct 170 ms 24608 KB Output is correct
5 Correct 145 ms 24664 KB Output is correct
6 Correct 147 ms 24660 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 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 424 KB Output is correct
13 Correct 154 ms 23124 KB Output is correct
14 Correct 161 ms 23632 KB Output is correct
15 Correct 147 ms 22348 KB Output is correct
16 Correct 151 ms 22992 KB Output is correct
17 Correct 231 ms 27220 KB Output is correct
18 Correct 233 ms 27092 KB Output is correct
19 Correct 233 ms 27140 KB Output is correct
20 Correct 237 ms 27012 KB Output is correct
21 Correct 226 ms 27212 KB Output is correct
22 Correct 248 ms 27216 KB Output is correct
23 Correct 218 ms 27036 KB Output is correct
24 Correct 223 ms 27196 KB Output is correct
25 Correct 163 ms 24524 KB Output is correct
26 Correct 165 ms 24608 KB Output is correct
27 Correct 246 ms 26788 KB Output is correct
28 Correct 249 ms 26976 KB Output is correct
29 Correct 236 ms 26648 KB Output is correct
30 Correct 244 ms 26708 KB Output is correct
31 Correct 230 ms 27088 KB Output is correct
32 Correct 152 ms 23188 KB Output is correct
33 Correct 1 ms 348 KB Output is correct