Submission #1097016

# Submission time Handle Problem Language Result Execution time Memory
1097016 2024-10-05T18:17:18 Z vladilius Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
253 ms 25484 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;
    vector<int> d(n + 1);
    for (int i = 1; i <= n; i++){
        cin>>d[i];
    }
    vector<int> k(n + 1);
    k[1] = d[1];
    for (int i = 2; i <= n; i++){
        k[i] = ceil(1.0 * d[i] / k[i - 1]) * k[i - 1];
    }
    vector<pii> all;
    int i = 1;
    while (i <= n){
        int j = i;
        while (j <= n && k[i] == k[j]){
            j++;
        }
        all.pb({i, j - 1});
        i = j;
    }
    
    while (q--){
        int t, l, r; cin>>t>>l>>r;
        int out = (l <= t && t <= r), p = t - 1;
        for (auto [L, R]: all){
            int f = (p + L) / k[L];
            int 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";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 153 ms 22668 KB Output is correct
2 Correct 148 ms 22680 KB Output is correct
3 Correct 152 ms 22636 KB Output is correct
4 Correct 157 ms 22740 KB Output is correct
5 Correct 147 ms 22756 KB Output is correct
6 Correct 149 ms 22656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 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 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 153 ms 22668 KB Output is correct
2 Correct 148 ms 22680 KB Output is correct
3 Correct 152 ms 22636 KB Output is correct
4 Correct 157 ms 22740 KB Output is correct
5 Correct 147 ms 22756 KB Output is correct
6 Correct 149 ms 22656 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 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 1 ms 348 KB Output is correct
13 Correct 167 ms 21332 KB Output is correct
14 Correct 163 ms 21840 KB Output is correct
15 Correct 153 ms 20452 KB Output is correct
16 Correct 164 ms 21072 KB Output is correct
17 Correct 228 ms 25172 KB Output is correct
18 Correct 227 ms 25312 KB Output is correct
19 Correct 227 ms 25384 KB Output is correct
20 Correct 218 ms 25168 KB Output is correct
21 Correct 215 ms 25428 KB Output is correct
22 Correct 214 ms 25464 KB Output is correct
23 Correct 227 ms 25148 KB Output is correct
24 Correct 213 ms 25484 KB Output is correct
25 Correct 151 ms 22628 KB Output is correct
26 Correct 155 ms 22612 KB Output is correct
27 Correct 220 ms 24912 KB Output is correct
28 Correct 253 ms 25172 KB Output is correct
29 Correct 237 ms 24796 KB Output is correct
30 Correct 237 ms 24888 KB Output is correct
31 Correct 233 ms 25168 KB Output is correct
32 Correct 157 ms 21332 KB Output is correct
33 Correct 0 ms 344 KB Output is correct