# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
479166 |
2021-10-10T13:58:25 Z |
Bogdan1110 |
Meteors (POI11_met) |
C++14 |
|
485 ms |
65540 KB |
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fi first
#define se second
#define ld long double
#define n_4 10010
#define n_5 100010
#define n_6 1000010
#define n_7 10000010
#define n_8 100000010
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ld, null_type,less<ld>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key -> # less than k
// find_by_order -> k-th element
// pq max element
const int NMAX = 1e6;
int N, M, K, l[NMAX], r[NMAX], L[NMAX], R[NMAX], res[NMAX];
ll bit[NMAX], potrebno[NMAX], x[NMAX];
vector<int>sec[NMAX];
vector<int>q[NMAX];
void update(int ind, ll koliko) {
while(ind < NMAX) {
bit[ind] += koliko;
ind += ind&(-ind);
}
}
ll query(int ind) {
ll sum = 0;
while(ind > 0) {
sum += bit[ind];
ind -= ind&-ind;
}
return sum;
}
void solve() {
cin >> N >> M;
for (int i = 1 ; i <= M ; i++ ) {
int o;
cin >> o;
sec[o].pb(i);
}
for (int i = 1 ; i <= N ; i++ ) {
int p ;
cin >> p;
potrebno[i] = p;
}
cin >> K;
for (int i = 1; i <= K ; i++) {
cin >> l[i] >> r[i] >> x[i];
}
for (int i = 1 ; i <= N ; i++ ) {
L[i] = 1;
R[i] = K;
res[i] = K+1;
//cout << sec[i].size() << endl;
}
bool changed = 1;
while(changed) {
changed = 0;
fill(bit, bit+NMAX, 0LL);
for (int i = 1 ; i <= K ; i++ ) q[i].clear();
for (int i = 1 ; i <= N ; i++ ) {
if ( L[i] <= R[i] ) {
changed = 1;
int mid = (L[i] + R[i])/2;
q[mid].pb(i);
}
}
for (int i = 1 ; i <= K ; i++ ) {
if ( l[i] <= r[i] ) {
update(l[i], x[i]);
update(r[i]+1, -x[i]);
}
else {
update(1,x[i]);
update(r[i]+1, -x[i]);
update(l[i], x[i]);
}
for (auto u : q[i]) {
ll sum = 0;
for (int s : sec[u]) {
sum += query(s);
//if ( sum >= potrebno[u] ) break;
}
if ( sum >= potrebno[u] ) {
res[u] = i;
R[u] = i-1;
}
else L[u] = i+1;
//cout << i << ' ' << u << ' ' << sum << endl ;
}
}
}
for (int i = 1 ; i <= N ; i++ ) {
//cout << L[i] << ' ' << R[i] << ' ';
if ( res[i] == K+1 ) {
puts("NIE");
}
else cout << res[i] << endl ;
}
}
int main () {
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
55108 KB |
Output is correct |
2 |
Correct |
43 ms |
55188 KB |
Output is correct |
3 |
Correct |
39 ms |
55144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
55092 KB |
Output is correct |
2 |
Correct |
36 ms |
55168 KB |
Output is correct |
3 |
Correct |
41 ms |
55224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
57508 KB |
Output is correct |
2 |
Correct |
265 ms |
60064 KB |
Output is correct |
3 |
Correct |
228 ms |
59460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
250 ms |
58832 KB |
Output is correct |
2 |
Correct |
233 ms |
58884 KB |
Output is correct |
3 |
Correct |
294 ms |
60204 KB |
Output is correct |
4 |
Correct |
96 ms |
57428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
207 ms |
57972 KB |
Output is correct |
2 |
Correct |
311 ms |
60704 KB |
Output is correct |
3 |
Correct |
228 ms |
56604 KB |
Output is correct |
4 |
Correct |
232 ms |
59992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
232 ms |
57236 KB |
Output is correct |
2 |
Correct |
267 ms |
59028 KB |
Output is correct |
3 |
Correct |
179 ms |
57724 KB |
Output is correct |
4 |
Correct |
279 ms |
61344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
440 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
485 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |