# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
622278 |
2022-08-04T05:46:53 Z |
jame0313 |
Meteors (POI11_met) |
C++17 |
|
2660 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;
using tii = tuple<int, int, int>;
// and so on
int arr[300001];
int goal[300001];
vector<vector<int> > lst, listeners;
vector<tii> Event, query;
struct bit {
ll tree[1 << 21], siz;
void init(int x) {
for (siz = 1; siz < x; siz <<= 1)
;
}
void clear() {
for (int i = 0; i <= siz; i++) tree[i] = 0;
}
void add(int pos, ll x) {
while (pos <= siz) {
tree[pos] += x;
pos += (pos & -pos);
}
}
ll sum(int pos) {
ll ret = 0;
while (pos) {
ret += tree[pos];
pos &= (pos - 1);
}
return ret;
}
} Tree;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int Q, N, M;
cin >> Q >> N;
lst.resize(Q + 1);
Tree.init(N + 1);
for (int i = 1; i <= N; i++) {
cin >> arr[i];
lst[arr[i]].push_back(i);
}
for (int i = 1; i <= Q; i++) {
cin >> goal[i];
}
cin >> M;
listeners.resize(M + 1);
for (int i = 0; i < M; i++) {
int l, r, c;
cin >> l >> r >> c;
Event.push_back({l, r, c});
}
for (int i = 0; i <= Q; i++) {
query.push_back({0, M-1, 0});
}
for (int t = 0; t < 32; t++) {
Tree.clear();
for (int i = 1; i <= Q; i++) {
auto& [l, r, m] = query[i];
//cout<<l<<' '<<r<<endl;
if (l <= r) {
m = (l + r) >> 1;
listeners[m].push_back(i);
}
}
for (int i = 0; i < M; i++) {
auto [l, r, c] = Event[i];
if(l<=r){
Tree.add(l, c);
Tree.add(r+1, -c);
}
else{
Tree.add(l, c);
Tree.add(N+1, -c);
Tree.add(1, c);
Tree.add(r+1, -c);
}
for (int j : listeners[i]) {
auto& [l, r, m] = query[j];
ll sum = 0;
for (int k : lst[j]){
sum += Tree.sum(k);
if(sum>=goal[j]) break;
}
if (sum < goal[j]) {
l = m + 1;
} else
r = m - 1;
}
listeners[i].clear();
}
}
for (int i = 1; i <= Q; i++) {
auto [l,r,m] = query[i];
if(l == M) cout<<"NIE\n";
else cout<<l+1<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
440 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
3768 KB |
Output is correct |
2 |
Correct |
196 ms |
6304 KB |
Output is correct |
3 |
Correct |
128 ms |
5544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
5004 KB |
Output is correct |
2 |
Correct |
159 ms |
4912 KB |
Output is correct |
3 |
Correct |
169 ms |
6384 KB |
Output is correct |
4 |
Correct |
31 ms |
3376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
4200 KB |
Output is correct |
2 |
Correct |
164 ms |
6868 KB |
Output is correct |
3 |
Correct |
73 ms |
2384 KB |
Output is correct |
4 |
Correct |
149 ms |
6096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
156 ms |
3268 KB |
Output is correct |
2 |
Correct |
188 ms |
5028 KB |
Output is correct |
3 |
Correct |
109 ms |
3444 KB |
Output is correct |
4 |
Correct |
202 ms |
7564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2041 ms |
32588 KB |
Output is correct |
2 |
Correct |
1887 ms |
17720 KB |
Output is correct |
3 |
Correct |
362 ms |
11724 KB |
Output is correct |
4 |
Correct |
2351 ms |
63032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1695 ms |
31196 KB |
Output is correct |
2 |
Correct |
1385 ms |
17704 KB |
Output is correct |
3 |
Correct |
307 ms |
11004 KB |
Output is correct |
4 |
Correct |
2660 ms |
65536 KB |
Output is correct |