# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
967417 |
2024-04-22T05:20:29 Z |
12345678 |
Meteors (POI11_met) |
C++17 |
|
1014 ms |
59796 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
const int nx=3e5+5;
int n, m, p[nx], q, l[nx], r[nx], ul, ur, a, cnt=19, t[nx];
vector<int> d[nx], qrs[nx];
vector<pair<int, pair<int, int>>> k;
struct fenwick
{
ll d[nx];
void update(int i, int vl)
{
while (i<nx) d[i]+=vl, i+=(i&-i);
}
ll query(int i)
{
ll res=0;
while (i>0) res+=d[i], i-=(i&-i);
return res;
}
} f;
int32_t main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=1; i<=m; i++) cin>>p[i], d[p[i]].push_back(i);
for (int i=1; i<=n; i++) cin>>t[i];
cin>>q;
for (int i=0; i<q; i++) cin>>ul>>ur>>a, k.push_back({a, {ul, ur}});
for (int i=1; i<=n; i++) l[i]=1, r[i]=q+1;
while (cnt--)
{
for (int i=1; i<=n; i++) qrs[(l[i]+r[i])/2].push_back(i);
for (int i=1; i<=q+1; i++)
{
if (i==q+1) continue;
int x=k[i-1].second.first, y=k[i-1].second.second, z=k[i-1].first;
if (x<=y) f.update(x, z), f.update(y+1, -z);
else f.update(1, z), f.update(y+1, -z), f.update(x, z), f.update(m+1, -z);
//cout<<"fenwick "<<i<<':';
//for (int j=1; j<=m; j++) cout<<f.query(j)<<' ';
//cout<<'\n';
for (auto idx:qrs[i])
{
ll sm=0;
for (auto id:d[idx]) sm+=f.query(id);
//cout<<"debug "<<cnt<<' '<<idx<<' '<<sm<<'\n';
if (sm>=t[idx]) r[idx]=i;
else l[idx]=i+1;
}
qrs[i].clear();
}
for (int i=1; i<=m+1; i++) f.d[i]=0;
}
for (int i=1; i<=n; i++)
{
if (l[i]>q) cout<<"NIE\n";
else cout<<l[i]<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
23128 KB |
Output is correct |
2 |
Correct |
7 ms |
23132 KB |
Output is correct |
3 |
Correct |
7 ms |
23036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
23128 KB |
Output is correct |
2 |
Correct |
7 ms |
23132 KB |
Output is correct |
3 |
Correct |
8 ms |
23132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
26828 KB |
Output is correct |
2 |
Correct |
222 ms |
32884 KB |
Output is correct |
3 |
Correct |
100 ms |
28384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
123 ms |
27848 KB |
Output is correct |
2 |
Correct |
123 ms |
27828 KB |
Output is correct |
3 |
Correct |
224 ms |
31940 KB |
Output is correct |
4 |
Correct |
30 ms |
26776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
27076 KB |
Output is correct |
2 |
Correct |
152 ms |
32564 KB |
Output is correct |
3 |
Correct |
136 ms |
24784 KB |
Output is correct |
4 |
Correct |
108 ms |
29128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
25780 KB |
Output is correct |
2 |
Correct |
156 ms |
27696 KB |
Output is correct |
3 |
Correct |
86 ms |
25984 KB |
Output is correct |
4 |
Correct |
145 ms |
33172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
856 ms |
59796 KB |
Output is correct |
2 |
Incorrect |
695 ms |
40904 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1014 ms |
56152 KB |
Output is correct |
2 |
Incorrect |
862 ms |
39876 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |