Submission #257904

# Submission time Handle Problem Language Result Execution time Memory
257904 2020-08-05T04:05:18 Z Autoratch Meteors (POI11_met) C++14
74 / 100
1127 ms 44796 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1 << 19;

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;
int fw[N];

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

int read(int idx){ if(idx==0) return 0; int 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;
    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);
                int m = (l[x]+r[x])/2;
                if(tmp>=need[x]) r[x] = m;
                else l[x] = m+1;
            }
            ask[i].clear();
        }
    }
    for(int i = 1;i <= n;i++)
    {
        if(l[i]==q)
        {
            int tmp = 0;
            for(int x : wh[i]) tmp+=read(x);
            if(tmp<need[i]) l[i] = -1;
        }
    }
    for(int i = 1;i <= n;i++) if(l[i]!=-1) 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 17 ms 25088 KB Output is correct
2 Correct 18 ms 25088 KB Output is correct
3 Correct 19 ms 25088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 25088 KB Output is correct
2 Correct 18 ms 25120 KB Output is correct
3 Correct 20 ms 25216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 26864 KB Output is correct
2 Correct 144 ms 29932 KB Output is correct
3 Correct 191 ms 29580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 140 ms 27888 KB Output is correct
2 Correct 177 ms 29040 KB Output is correct
3 Correct 153 ms 30192 KB Output is correct
4 Correct 48 ms 27640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 27244 KB Output is correct
2 Correct 157 ms 30576 KB Output is correct
3 Correct 106 ms 26492 KB Output is correct
4 Correct 122 ms 29940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 26460 KB Output is correct
2 Correct 129 ms 29160 KB Output is correct
3 Correct 91 ms 27756 KB Output is correct
4 Correct 149 ms 31472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 952 ms 44796 KB Output is correct
2 Incorrect 1127 ms 41060 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1053 ms 43436 KB Output is correct
2 Incorrect 622 ms 39648 KB Output isn't correct
3 Halted 0 ms 0 KB -