답안 #644045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644045 2022-09-23T15:46:20 Z ttamx Meteors (POI11_met) C++14
74 / 100
922 ms 29704 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef tuple<int,int,int> t3;

const int N=3e5+5;

struct fenwick{
    ll tree[N]={};
    void init(){
        for(int i=0;i<N;++i)tree[i]=0;
    }
    void add(int i,ll v){
        while(i<N){
            tree[i]+=v;
            i+=i&-i;
        }
    }
    ll read(int i){
        ll sum=0;
        while(i>0){
            sum+=tree[i];
            i-=i&-i;
        }
        return sum;
    }
}f;

int n,m,k;
int l[N],r[N],ans[N];
ll p[N];
vector<int> o[N];
vector<t3> v;

int main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	cin >> n >> m;
	for(int i=1;i<=m;++i){
        int x;
        cin >> x;
        o[x].push_back(i);
	}
	for(int i=1;i<=n;++i)cin >> p[i];
    cin >> k;
    v.emplace_back(0,0,0);
    for(int i=1;i<=k;++i){
        int a,b,c;
        cin >> a >> b >> c;
        v.emplace_back(a,b,c);
    }
    for(int i=1;i<=n;++i)l[i]=1,r[i]=k+1;
    while(true){
        vector<int> res[k+2];
        int cnt=0;
        for(int i=1;i<=n;++i){
            if(l[i]>=r[i])continue;
            res[(l[i]+r[i])/2].emplace_back(i);
            ++cnt;
        }
        if(cnt==0)break;
        f.init();
        for(int i=1;i<=k;++i){
            auto [a,b,c]=v[i];
            f.add(a,c);
            f.add(b+1,-c);
            if(b<a){
                f.add(1,c);
                f.add(m+1,-c);
            }
            for(auto j:res[i]){
                ll sum=0;
                for(auto x:o[j])sum+=f.read(x);
                if(sum>=p[j])r[j]=i;
                else l[j]=i+1;
                if(l[j]>=r[j])ans[j]=r[j];
            }
        }
    }
    for(int i=1;i<=n;++i){
        if(ans[i]<=k)cout << ans[i] << '\n';
        else cout << "NIE" << '\n';
    }
	return 0;
}

Compilation message

met.cpp: In function 'int main()':
met.cpp:65:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   65 |             auto [a,b,c]=v[i];
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9728 KB Output is correct
2 Correct 7 ms 9812 KB Output is correct
3 Correct 7 ms 9804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9684 KB Output is correct
2 Correct 7 ms 9684 KB Output is correct
3 Correct 7 ms 9812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 12032 KB Output is correct
2 Correct 134 ms 12860 KB Output is correct
3 Correct 107 ms 12596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 120 ms 12300 KB Output is correct
2 Correct 130 ms 13408 KB Output is correct
3 Correct 138 ms 14172 KB Output is correct
4 Correct 31 ms 11340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 12064 KB Output is correct
2 Correct 140 ms 14348 KB Output is correct
3 Correct 122 ms 12212 KB Output is correct
4 Correct 99 ms 13936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 11948 KB Output is correct
2 Correct 145 ms 12320 KB Output is correct
3 Correct 85 ms 13008 KB Output is correct
4 Correct 134 ms 14520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 919 ms 27472 KB Output is correct
2 Incorrect 558 ms 29704 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 922 ms 26832 KB Output is correct
2 Incorrect 659 ms 28220 KB Output isn't correct
3 Halted 0 ms 0 KB -