# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
548561 |
2022-04-13T19:51:27 Z |
2fat2code |
Meteors (POI11_met) |
C++17 |
|
691 ms |
36592 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define fr first
#define sc second
#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int nmax = 300005;
int n, m, k, a[nmax], p[nmax], x[nmax], y[nmax], z[nmax], ans[nmax], curr, tree[nmax];
vector<int>members[nmax];
void add(int pos, int val){
for(int i=pos;i<nmax;i+=(i&-i)){
tree[i] += val;
}
}
int query(int pos){
int ans = 0;
for(int i=pos;i>=1;i-=(i&-i)){
ans += tree[i];
}
return ans;
}
void rec(int l, int r, vector<int>&pending){
if(r < l) return;
int mid = l + (r - l) / 2;
while(curr < mid){
curr++;
if(x[curr] <= y[curr]){
add(x[curr], z[curr]);
add(y[curr]+1, (-1LL)*z[curr]);
}
else{
add(x[curr], z[curr]);
add(m+1, (-1LL)*z[curr]);
add(1, z[curr]);
add(y[curr]+1, (-1LL)*z[curr]);
}
}
while(curr > mid){
int fuck = z[curr] * (-1LL);
if(x[curr] <= y[curr]){
add(x[curr], fuck);
add(y[curr]+1, (-1LL)*fuck);
}
else{
add(x[curr], fuck);
add(m+1, (-1LL)*fuck);
add(1, fuck);
add(y[curr]+1, (-1LL)*fuck);
}
--curr;
}
vector<int>good;
vector<int>bad;
for(auto it : pending){
int curr = 0;
for(auto it1 : members[it]){
curr += (query(it1));
}
if(curr >= p[it]){
good.push_back(it);
ans[it] = mid;
}
else{
bad.push_back(it);
}
}
pending.clear();
if(l != r){
rec(l, mid - 1, good);
rec(mid + 1, r, bad);
}
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
//freopen("input.in", "r", stdin);
cin >> n >> m;
for(int i=1;i<=m;i++){
cin >> a[i];
members[a[i]].push_back(i);
}
for(int i=1;i<=n;i++){ cin >> p[i];}
cin >> k;
for(int i=1;i<=k;i++){
cin >> x[i] >> y[i] >> z[i];
assert(1 <= x[i] && x[i] <= m);
assert(1 <= y[i] && y[i] <= m);
}
vector<int>tz;
for(int i=1;i<=n;i++) tz.push_back(i);
rec(1, k, tz);
for(int i=1;i<=n;i++){
if(!ans[i]){
cout << "NIE" << '\n';
}
else{
cout << ans[i] << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7508 KB |
Output is correct |
2 |
Correct |
5 ms |
7508 KB |
Output is correct |
3 |
Correct |
5 ms |
7524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7532 KB |
Output is correct |
2 |
Correct |
6 ms |
7508 KB |
Output is correct |
3 |
Correct |
7 ms |
7508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
10808 KB |
Output is correct |
2 |
Correct |
108 ms |
14120 KB |
Output is correct |
3 |
Correct |
69 ms |
10828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
10528 KB |
Output is correct |
2 |
Correct |
99 ms |
10572 KB |
Output is correct |
3 |
Correct |
114 ms |
12752 KB |
Output is correct |
4 |
Correct |
28 ms |
10420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
10472 KB |
Output is correct |
2 |
Correct |
106 ms |
13004 KB |
Output is correct |
3 |
Correct |
71 ms |
8676 KB |
Output is correct |
4 |
Correct |
75 ms |
11096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
9928 KB |
Output is correct |
2 |
Correct |
97 ms |
10536 KB |
Output is correct |
3 |
Correct |
52 ms |
10028 KB |
Output is correct |
4 |
Correct |
97 ms |
12160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
691 ms |
36592 KB |
Output is correct |
2 |
Incorrect |
456 ms |
21524 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
647 ms |
33196 KB |
Output is correct |
2 |
Incorrect |
503 ms |
21580 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |