# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
644040 |
2022-09-23T15:37:43 Z |
ttamx |
Meteors (POI11_met) |
C++14 |
|
6000 ms |
25128 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 o[N],l[N],r[N],ans[N];
ll p[N];
ll sum[N];
vector<t3> v;
vector<int> res[N];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> m;
for(int i=1;i<=m;++i)cin >> o[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){
for(int i=1;i<=k;++i)res[i].clear();
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;
for(int i=1;i<=k;++i){
if(res[i].empty())continue;
f.init();
for(int j=1;j<=i;++j){
auto [a,b,c]=v[j];
f.add(a,c);
f.add(b+1,-c);
if(b<a){
f.add(1,c);
f.add(m+1,-c);
}
}
for(int j=1;j<=n;++j)sum[j]=0;
for(int j=1;j<=m;++j)sum[o[j]]+=f.read(j);
for(auto j:res[i]){
if(sum[j]>=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:64:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
64 | auto [a,b,c]=v[j];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
9684 KB |
Output is correct |
2 |
Correct |
23 ms |
9812 KB |
Output is correct |
3 |
Correct |
77 ms |
9788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
9684 KB |
Output is correct |
2 |
Correct |
8 ms |
9812 KB |
Output is correct |
3 |
Correct |
98 ms |
9844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
11056 KB |
Output is correct |
2 |
Correct |
2178 ms |
14176 KB |
Output is correct |
3 |
Execution timed out |
6028 ms |
12692 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6050 ms |
11468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6060 ms |
11172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2124 ms |
10672 KB |
Output is correct |
2 |
Execution timed out |
6053 ms |
12596 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6094 ms |
25128 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6067 ms |
22452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |