# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
555082 |
2022-04-30T06:46:28 Z |
myungwoo |
Meteors (POI11_met) |
C++17 |
|
930 ms |
35440 KB |
#include <bits/stdc++.h>
using namespace std;
using lld = long long;
constexpr int MAXN = 300005;
int N, M, Q;
int O[MAXN], P[MAXN];
vector<int> locations[MAXN];
tuple<int, int, int> queries[MAXN];
vector<int> points[MAXN];
struct BIT{
BIT(int sz): sz(sz), tree(sz+1){}
void update(int n, int v){
for (;n<=sz;n+=n&-n) tree[n] += v;
}
void update(int l, int r, int v){
update(l, v), update(r+1, -v);
}
lld get(int n){
lld ret = 0;
for (;n;n^=n&-n) ret += tree[n];
return ret;
}
void clear(){
fill(begin(tree), end(tree), 0);
}
int sz;
vector<lld> tree;
};
int main(){
scanf("%d%d", &N, &M);
for (int i=1;i<=M;i++) scanf("%d", O+i), locations[O[i]].push_back(i);
for (int i=1;i<=N;i++) scanf("%d", P+i);
scanf("%d", &Q);
for (int i=1;i<=Q;i++){
auto& [l, r, a] = queries[i];
scanf("%d%d%d", &l, &r, &a);
}
BIT bit(M);
vector<int> S(N+1, 1), E(N+1, Q), ans(N+1);
for (;;){
int last = 0;
for (int i=1;i<=N;i++) if (S[i] <= E[i]){
int m = S[i]+E[i] >> 1;
last = max(last, m);
points[m].push_back(i);
}
if (!last) break;
for (int q=1;q<=last;q++){
auto [l, r, a] = queries[q];
if (l <= r) bit.update(l, r, a);
else bit.update(l, M, a), bit.update(1, r, a);
for (int i: points[q]){
lld cnt = 0;
for (int loc: locations[i]) cnt += bit.get(loc);
if (cnt >= P[i]) E[i] = q-1, ans[i] = q;
else S[i] = q+1;
}
points[q].clear();
}
bit.clear();
}
for (int i=1;i<=N;i++){
if (ans[i]) printf("%d\n", ans[i]);
else puts("NIE");
}
}
Compilation message
met.cpp: In function 'int main()':
met.cpp:47:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
47 | int m = S[i]+E[i] >> 1;
met.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | scanf("%d%d", &N, &M);
| ~~~~~^~~~~~~~~~~~~~~~
met.cpp:35:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | for (int i=1;i<=M;i++) scanf("%d", O+i), locations[O[i]].push_back(i);
| ~~~~~^~~~~~~~~~~
met.cpp:36:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | for (int i=1;i<=N;i++) scanf("%d", P+i);
| ~~~~~^~~~~~~~~~~
met.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | scanf("%d", &Q);
| ~~~~~^~~~~~~~~~
met.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%d%d%d", &l, &r, &a);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
14420 KB |
Output is correct |
2 |
Correct |
9 ms |
14420 KB |
Output is correct |
3 |
Correct |
9 ms |
14428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14412 KB |
Output is correct |
2 |
Correct |
8 ms |
14420 KB |
Output is correct |
3 |
Correct |
8 ms |
14504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
16276 KB |
Output is correct |
2 |
Correct |
104 ms |
18388 KB |
Output is correct |
3 |
Correct |
94 ms |
17988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
118 ms |
17468 KB |
Output is correct |
2 |
Correct |
91 ms |
17488 KB |
Output is correct |
3 |
Correct |
101 ms |
18524 KB |
Output is correct |
4 |
Correct |
34 ms |
16828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
16788 KB |
Output is correct |
2 |
Correct |
85 ms |
19148 KB |
Output is correct |
3 |
Correct |
41 ms |
15036 KB |
Output is correct |
4 |
Correct |
99 ms |
18456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
15820 KB |
Output is correct |
2 |
Correct |
89 ms |
17484 KB |
Output is correct |
3 |
Correct |
81 ms |
16204 KB |
Output is correct |
4 |
Correct |
147 ms |
19728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
908 ms |
35440 KB |
Output is correct |
2 |
Incorrect |
753 ms |
22804 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
930 ms |
33936 KB |
Output is correct |
2 |
Incorrect |
530 ms |
22744 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |