Submission #257944

# Submission time Handle Problem Language Result Execution time Memory
257944 2020-08-05T05:40:55 Z Autoratch Meteors (POI11_met) C++14
100 / 100
2285 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 2;

int n,m,q;
int bl[N],need[N];
vector<int> wh[N];
int l[N],r[N];
vector<int> ask[N];
vector<tuple<int,int,int> > inp;
long long fw[N];

void update(int idx,long long val){ while(idx<N) fw[idx]+=val,idx+=(idx & -idx); }

long long read(int idx){ if(idx==0) return 0; long long val = 0; while(idx>0) val+=fw[idx],idx-=(idx & -idx); return val; }

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m;
    for(int i = 1;i <= m;i++) cin >> bl[i],wh[bl[i]].push_back(i);
    for(int i = 1;i <= n;i++) cin >> need[i];
    cin >> q;
    for(int i = 1;i <= q;i++)
    {
        int l,r,k;
        cin >> l >> r >> k;
        inp.push_back({l,r,k});
    }
    for(int i = 1;i <= n;i++) l[i] = 1,r[i] = q+1;
    while(true)
    {
        bool done = true;
        for(int i = 1;i <= n;i++) if(l[i]<r[i]) done = false,ask[(l[i]+r[i])/2].push_back(i);
        if(done) break;
        for(int i = 1;i <= m;i++) fw[i] = 0;
        for(int i = 1;i <= q;i++)
        {
            auto [ll,rr,k] = inp[i-1];
            if(ll<=rr) update(ll,k),update(rr+1,-k);
            else update(1,k),update(rr+1,-k),update(ll,k);
            for(int x : ask[i]) 
            {
                long long tmp = 0;
                for(int y : wh[x]){ tmp+=read(y); if(tmp>1e9) tmp = 1e9 + 1; }
                if(tmp>=need[x]) r[x] = i;
                else l[x] = i+1;
            }
            ask[i].clear();
        }
    }
    for(int i = 1;i <= n;i++) if(l[i]<=q) cout << l[i] << '\n'; else cout << "NIE\n";
}

Compilation message

met.cpp: In function 'int main()':
met.cpp:41:18: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
             auto [ll,rr,k] = inp[i-1];
                  ^
# Verdict Execution time Memory Grader output
1 Correct 11 ms 14592 KB Output is correct
2 Correct 11 ms 14592 KB Output is correct
3 Correct 13 ms 14592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14592 KB Output is correct
2 Correct 11 ms 14592 KB Output is correct
3 Correct 11 ms 14592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 16496 KB Output is correct
2 Correct 161 ms 18416 KB Output is correct
3 Correct 114 ms 18144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 143 ms 17724 KB Output is correct
2 Correct 137 ms 17516 KB Output is correct
3 Correct 153 ms 18540 KB Output is correct
4 Correct 39 ms 16888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 17008 KB Output is correct
2 Correct 178 ms 19056 KB Output is correct
3 Correct 126 ms 15356 KB Output is correct
4 Correct 122 ms 18412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 137 ms 16360 KB Output is correct
2 Correct 148 ms 17524 KB Output is correct
3 Correct 94 ms 16368 KB Output is correct
4 Correct 153 ms 19696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1086 ms 35416 KB Output is correct
2 Correct 744 ms 23384 KB Output is correct
3 Correct 678 ms 17652 KB Output is correct
4 Correct 2110 ms 62312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1182 ms 34136 KB Output is correct
2 Correct 752 ms 23400 KB Output is correct
3 Correct 578 ms 17640 KB Output is correct
4 Correct 2285 ms 65536 KB Output is correct