# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
920494 |
2024-02-02T15:44:15 Z |
NotLinux |
Meteors (POI11_met) |
C++17 |
|
2016 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
#define lng __int128
const int N = 1e6 + 7;
const int gh = 21;
lng fen[N];
struct FENWICK{
int sz;
FENWICK(int x){
sz = x+3;
fill(fen , fen + x , 0);
}
inline void update(int p , int x) {
while(p <= sz){
fen[p] += x;
p += p & (-p);
//cout << "update:" << p << " " << sz << endl;
}
}
inline lng query(int x){
lng ret = 0;
while(x != 0){
ret += fen[x];
x -= x & (-x);
//cout <<"query:"<< x << endl;
}
return ret;
}
inline void rangeupdate(int l , int r,int x){
update(l,x);
if(r != sz)update(r+1,-x);
}
};
void solve(){
int n,m;cin >> n >> m;
vector < int > devlet[n+1];
for(int i = 1;i<=m;i++){
int x;cin >> x;
devlet[x].push_back(i);
}
int need[n+1];
for(int i = 1;i<=n;i++){
cin >> need[i];
}
int q;cin >> q;
vector < array < int , 3 > > query(q+1);
for(int i = 1;i<=q;i++){
cin >> query[i][0] >> query[i][1] >> query[i][2];
}
vector < int > paralel[q+2],nparalel[q+2];
int l[n+1] , r[n+1];
for(int i = 1;i<=n;i++){
l[i] = 1;
r[i] = q+1;
paralel[(l[i] + r[i])/2].push_back(i);
}
for(int i = 0;i<=gh;i++){
FENWICK fen(m+10);
for(int j = 1;j<=q;j++){
if(query[j][0] <= query[j][1]){
fen.rangeupdate(query[j][0],query[j][1],query[j][2]);
}
else{
fen.rangeupdate(1,query[j][1],query[j][2]);
fen.rangeupdate(query[j][0],m+1,query[j][2]);
}
for(auto itr : paralel[j]){
if(l[itr] == r[itr]){
nparalel[j].push_back(itr);
continue;
}
lng cur = 0;
for(auto itr1 : devlet[itr]){
cur += fen.query(itr1);
}
int mid = (l[itr] + r[itr])/2;
if(cur >= need[itr]){//r = mid;
r[itr] = mid;
}
else {//l = mid
l[itr] = mid+1;
}
nparalel[(l[itr] + r[itr]) / 2].push_back(itr);
}
}
for(int j = 1;j<=q;j++){
paralel[j].swap(nparalel[j]);
nparalel[j].clear();
}
}
int ans[n+1];
memset(ans , -1 , sizeof(ans));
for(int j = 1;j<=q;j++){
for(auto itr : paralel[j]){
ans[itr] = j;
}
}
for(int i = 1;i<=n;i++){
if(ans[i] == -1)cout << "NIE" << '\n';
else cout << ans[i] << '\n';
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
6484 KB |
Output is correct |
2 |
Correct |
120 ms |
9108 KB |
Output is correct |
3 |
Correct |
122 ms |
8688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
7800 KB |
Output is correct |
2 |
Correct |
113 ms |
7820 KB |
Output is correct |
3 |
Correct |
125 ms |
9296 KB |
Output is correct |
4 |
Correct |
27 ms |
5080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
7036 KB |
Output is correct |
2 |
Correct |
94 ms |
9740 KB |
Output is correct |
3 |
Correct |
61 ms |
3460 KB |
Output is correct |
4 |
Correct |
103 ms |
9068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
5996 KB |
Output is correct |
2 |
Correct |
116 ms |
7760 KB |
Output is correct |
3 |
Correct |
89 ms |
6376 KB |
Output is correct |
4 |
Correct |
127 ms |
10744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
998 ms |
41100 KB |
Output is correct |
2 |
Correct |
570 ms |
25708 KB |
Output is correct |
3 |
Correct |
297 ms |
15556 KB |
Output is correct |
4 |
Runtime error |
1821 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1028 ms |
39384 KB |
Output is correct |
2 |
Correct |
540 ms |
25704 KB |
Output is correct |
3 |
Correct |
244 ms |
12056 KB |
Output is correct |
4 |
Runtime error |
2016 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |