# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
605592 |
2022-07-25T19:18:26 Z |
1ne |
Meteors (POI11_met) |
C++14 |
|
6000 ms |
18520 KB |
#include<bits/stdc++.h>
using namespace std;
struct node{
long long l,r,v;
};
const int maxn = 300005;
long long tree[maxn];
int m;
void update(int x, long long val){
while(x<=m){
tree[x]+=val;
x+=(x&-x);
}
}
long long read(int x){
long long s=0;
while(x>0){
s+=tree[x];
x-=(x&-x);
}
return s;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n>>m;
vector<vector<int>>arr(n);
for (int i = 0;i<m;++i){
int x;cin>>x;
arr[x - 1].push_back(i);
}
vector<long long>brr(n);
for (int i = 0;i<n;++i)cin>>brr[i];
int k;cin>>k;
vector<node>edge(k);
for (int i = 0;i<k;++i){
cin>>edge[i].l>>edge[i].r>>edge[i].v;
edge[i].l--;
edge[i].r--;
}
vector<int>l(n),r(n);
queue<int>q;
int pos = -1;
for (int i = 0;i<n;++i){
q.push(i);
l[i] = 0,r[i] = k;
}
vector<int>ans(n,-1);
while(!q.empty()){
int u = q.front();
q.pop();
if (l[u] == r[u]){
ans[u] = l[u];
continue;
}
int mid = (l[u] + r[u])>>1;
if (pos > mid){
for (int i = mid + 1;i<=pos;++i){
if (edge[i].l<=edge[i].r){
update(edge[i].l + 1,-edge[i].v),update(edge[i].r + 2,edge[i].v);
}
else{
update(1,-edge[i].v);
update(edge[i].r + 2,edge[i].v);
update(edge[i].r + 1,-edge[i].v);
}
}
pos = mid;
}
else{
for (int i = pos + 1;i<=mid;++i){
if (edge[i].l<=edge[i].r){
update(edge[i].l + 1,edge[i].v),update(edge[i].r + 2,-edge[i].v);
}
else{
update(1,edge[i].v);
update(edge[i].r + 2,-edge[i].v);
update(edge[i].l + 1,edge[i].v);
}
}
pos = mid;
}
long long counts = 0;
for (auto x:arr[u]){
counts+=read(x + 1);
if (counts >=brr[u])break;
}
if (counts < brr[u]){
q.push(u);
l[u] = mid + 1;
}
else {
q.push(u);
r[u] = mid;
}
}
for (auto x:ans){
x++;
if (x > k)cout<<"NIE\n";
else cout<<x<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
89 ms |
2420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6037 ms |
2724 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6024 ms |
2496 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
362 ms |
2228 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
883 ms |
18520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6011 ms |
17228 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |