Submission #1011671

# Submission time Handle Problem Language Result Execution time Memory
1011671 2024-07-01T04:28:24 Z snpmrnhlol Worst Reporter 3 (JOI18_worst_reporter3) C++17
0 / 100
404 ms 32388 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5;
int v[N];
array <int,3> trains[N + 1];
struct query{
    int t,l,r,id;
}q2[N];
int ans[N];
int main(){
    int n,q;
    cin>>n>>q;
    for(int i = 0;i < n;i++){
        cin>>v[i];
        if(i){
            if(v[i]%v[i - 1] == 0){
                v[i] = v[i]/v[i - 1]*v[i - 1];
            }else{
                v[i] = v[i]/v[i - 1]*v[i - 1] + v[i - 1];
            }
        }
    }
    int cnt = 0;
    trains[cnt++] = {0,0,1};
    int nr = 0;
    for(int i = 0;i < n;i++){
        if(i && v[i] != v[i - 1]){
            trains[cnt++] = {-i,-i + nr - 1,v[i - 1]};
            nr = 1;
        }else nr++;
    }
    trains[cnt++] = {-n,-n + nr - 1,v[n - 1]};
    ///l,r,jumppower
    for(int i = 0;i < q;i++){
        cin>>q2[i].t>>q2[i].l>>q2[i].r;
        q2[i].id = i;
    }
    sort(q2,q2 + q,[&](query a,query b){
         return a.t < b.t;
    });
    int timp = 0;
    for(int i = 0;i < q;i++){
        trains[0][0]+=q2[i].t - timp;
        trains[0][1]+=q2[i].t - timp;
        for(int j = 1;j < cnt;j++){
            if(trains[j][1] < trains[j - 1][0] - trains[j][2]){
                int sum = (trains[j - 1][0] - trains[j][1])/trains[j][2];
                trains[j][0]+=sum*trains[j][2];
                trains[j][1]+=sum*trains[j][2];
            }
        }
        //cout<<q2[i].t<<'\n';
        int score = 0;
        for(int j = 0;j < cnt;j++){
            //cout<<trains[j][0]<<' '<<trains[j][1]<<' '<<trains[j][2]<<'\n';
            score+=max(0,min(q2[i].r,trains[j][1]) - max(q2[i].l,trains[j][0]) + 1);
        }
        ans[q2[i].id] = score;
        timp = q2[i].t;
    }
    for(int i = 0;i < q;i++){
        cout<<ans[i]<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 404 ms 32388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Incorrect 1 ms 6492 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 404 ms 32388 KB Output isn't correct
2 Halted 0 ms 0 KB -