Submission #206698

# Submission time Handle Problem Language Result Execution time Memory
206698 2020-03-04T16:02:59 Z nvmdava Worst Reporter 3 (JOI18_worst_reporter3) C++17
0 / 100
318 ms 20728 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] / 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 Incorrect 318 ms 20728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 318 ms 20728 KB Output isn't correct
2 Halted 0 ms 0 KB -