# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
644050 |
2022-09-23T16:03:15 Z |
ttamx |
Meteors (POI11_met) |
C++14 |
|
1582 ms |
44132 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];
bool can[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])break;
}
if(sum>=p[j])r[j]=i;
else l[j]=i+1;
}
}
}
for(int i=1;i<=n;++i){
if(r[i]<=k)cout << r[i] << '\n';
else cout << "NIE" << '\n';
}
return 0;
}
Compilation message
met.cpp: In function 'int main()':
met.cpp:66:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
66 | auto [a,b,c]=v[i];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9684 KB |
Output is correct |
2 |
Correct |
8 ms |
9684 KB |
Output is correct |
3 |
Correct |
7 ms |
9684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
9684 KB |
Output is correct |
2 |
Correct |
8 ms |
9704 KB |
Output is correct |
3 |
Correct |
7 ms |
9812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
11968 KB |
Output is correct |
2 |
Correct |
150 ms |
12748 KB |
Output is correct |
3 |
Correct |
96 ms |
12492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
12196 KB |
Output is correct |
2 |
Correct |
115 ms |
12204 KB |
Output is correct |
3 |
Correct |
156 ms |
12920 KB |
Output is correct |
4 |
Correct |
30 ms |
10876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
12060 KB |
Output is correct |
2 |
Correct |
131 ms |
13040 KB |
Output is correct |
3 |
Correct |
128 ms |
11640 KB |
Output is correct |
4 |
Correct |
131 ms |
12680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
11948 KB |
Output is correct |
2 |
Correct |
139 ms |
12236 KB |
Output is correct |
3 |
Correct |
79 ms |
11972 KB |
Output is correct |
4 |
Correct |
151 ms |
13220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
873 ms |
27080 KB |
Output is correct |
2 |
Correct |
515 ms |
21860 KB |
Output is correct |
3 |
Correct |
651 ms |
21044 KB |
Output is correct |
4 |
Correct |
1488 ms |
42088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
890 ms |
26552 KB |
Output is correct |
2 |
Correct |
638 ms |
21824 KB |
Output is correct |
3 |
Correct |
522 ms |
20284 KB |
Output is correct |
4 |
Correct |
1582 ms |
44132 KB |
Output is correct |