Submission #206699

# Submission time Handle Problem Language Result Execution time Memory
206699 2020-03-04T16:04:30 Z nvmdava Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
467 ms 23440 KB
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define ff first
#define ss second
#define N 500005
#define MOD 1000000007
#define INF 0x3f3f3f3f

int a[N];

vector<pair<int, pair<int, int> > > v;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin>>n>>q;
    
    for(int i = 1; i <= n; ++i)
        cin>>a[i];
    for(int i = 2; i <= n; ++i)
        a[i] = ((a[i] - 1) / a[i - 1] + 1) * a[i - 1];

    for(int i = 1; i <= n; ++i){
        if(a[i] != a[i - 1]){
            v.push_back({a[i], {-i, -i}});
        } else {
            v.back().ss.ff = -i;
        }
    }

    while(q--){
        int t, l, r;
        cin>>t>>l>>r;
        int m = t;
        int res = 0;
        if(l <= m && m <= r)
            ++res;
        for(auto& x : v){
            int L = x.ss.ff, R = x.ss.ss;
            int val = (m - R - 1) / x.ff * x.ff;
            L += val;
            R += val;
            res += max(0, min(R, r) - max(l, L) + 1);
            m = L;
        }
        cout<<res<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 314 ms 5396 KB Output is correct
2 Correct 314 ms 20728 KB Output is correct
3 Correct 305 ms 20728 KB Output is correct
4 Correct 314 ms 20728 KB Output is correct
5 Correct 322 ms 20892 KB Output is correct
6 Correct 304 ms 20728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 424 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 314 ms 5396 KB Output is correct
2 Correct 314 ms 20728 KB Output is correct
3 Correct 305 ms 20728 KB Output is correct
4 Correct 314 ms 20728 KB Output is correct
5 Correct 322 ms 20892 KB Output is correct
6 Correct 304 ms 20728 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 5 ms 424 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 327 ms 19344 KB Output is correct
14 Correct 323 ms 19832 KB Output is correct
15 Correct 313 ms 18552 KB Output is correct
16 Correct 325 ms 19192 KB Output is correct
17 Correct 467 ms 23344 KB Output is correct
18 Correct 446 ms 23376 KB Output is correct
19 Correct 432 ms 23416 KB Output is correct
20 Correct 427 ms 23288 KB Output is correct
21 Correct 430 ms 23440 KB Output is correct
22 Correct 431 ms 23416 KB Output is correct
23 Correct 415 ms 23288 KB Output is correct
24 Correct 429 ms 23400 KB Output is correct
25 Correct 319 ms 20748 KB Output is correct
26 Correct 333 ms 21000 KB Output is correct
27 Correct 438 ms 22852 KB Output is correct
28 Correct 456 ms 23292 KB Output is correct
29 Correct 440 ms 22820 KB Output is correct
30 Correct 455 ms 22908 KB Output is correct
31 Correct 448 ms 23252 KB Output is correct
32 Correct 301 ms 19324 KB Output is correct
33 Correct 5 ms 376 KB Output is correct