# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
622272 |
2022-08-04T05:33:32 Z |
jame0313 |
Meteors (POI11_met) |
C++17 |
|
1871 ms |
32848 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, 0});
}
for (int t = 0; t < 32; t++) {
Tree.clear();
for (int i = 1; i <= Q; i++) {
auto& [l, r, m] = query[i];
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]) {
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 |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
4552 KB |
Output is correct |
2 |
Correct |
179 ms |
8612 KB |
Output is correct |
3 |
Correct |
140 ms |
5776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
178 ms |
5024 KB |
Output is correct |
2 |
Correct |
171 ms |
4988 KB |
Output is correct |
3 |
Correct |
183 ms |
6856 KB |
Output is correct |
4 |
Correct |
37 ms |
4428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
4384 KB |
Output is correct |
2 |
Correct |
175 ms |
9284 KB |
Output is correct |
3 |
Correct |
72 ms |
2384 KB |
Output is correct |
4 |
Correct |
127 ms |
6312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
155 ms |
3272 KB |
Output is correct |
2 |
Correct |
167 ms |
5072 KB |
Output is correct |
3 |
Correct |
103 ms |
3604 KB |
Output is correct |
4 |
Correct |
202 ms |
8428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1863 ms |
32848 KB |
Output is correct |
2 |
Incorrect |
1871 ms |
17852 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1674 ms |
31308 KB |
Output is correct |
2 |
Incorrect |
1330 ms |
17796 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |