## Submission #926325

# Submission time Handle Problem Language Result Execution time Memory
926325 2024-02-12T19:27:13 Z VMaksimoski008 Meteors (POI11_met) C++14
0 / 100
136 ms 65536 KB
```#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

struct BIT {
int n;
vector<ll> tree;

void config(int _n) {
n = _n + 10;
tree.resize(_n+60);
}

void add(int p, int v) {
for(p++; p<n; p+=p&-p) tree[p] += v;
}

ll query(int p) {
ll ans = 0;
for(p++; p>0; p-=p&-p) ans += tree[p];
return ans;
}

ll sum(int l, int r) { return query(r) - query(l-1); }
void clear() { for(ll &x : tree) x = 0; }
};

struct Query { int l, r, x; };

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int n, m, req[n+5], k, it, i;
ll total = 0;
cin >> n >> m;

vector<int> owner[n+5];
for(i=1; i<=m; i++) {
int x;
cin >> x;
owner[x].push_back(i);
}

for(i=1; i<=n; i++) cin >> req[i];

cin >> k;
Query qus[k+5], q;
for(i=1; i<=k; i++)
cin >> qus[i].l >> qus[i].r >> qus[i].x;

vector<int> L(n+5, 1), R(n+5, k+1);
bool changed = true;

BIT bit;
bit.config(m+1);
vector<stack<int> > to_check(k+5);
while(changed) {
changed = false;

bit.clear();

for(int i=1; i<=n; i++)
if(L[i] != R[i]) to_check[(L[i]+R[i])/2].push(i);

for(it=1; it<=k; it++) {
q = qus[it];

if(q.l <= q.r) {
} else {

}

while(!to_check[it].empty()) {
changed = true;

int u = to_check[it].top();
to_check[it].pop();

total = 0;
for(int &x : owner[u]) {
total += bit.query(x);
if(total > req[u]) break;
}

if(total >= req[u]) R[u] = it;
else L[u] = it + 1;
}
}
}

for(i=1; i<=n; i++) {
if(L[i] <= k) cout << L[i] << '\n';
else cout << "NIE\n";
}
return 0;
}```

#### Subtask #1 0 / 12.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Runtime error 136 ms 65536 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -

#### Subtask #2 0 / 12.0

# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 13404 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #3 0 / 12.0

# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1372 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #4 0 / 12.0

# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -

#### Subtask #5 0 / 13.0

# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 1372 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #6 0 / 13.0

# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -

#### Subtask #7 0 / 13.0

# Verdict Execution time Memory Grader output
1 Runtime error 71 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -

#### Subtask #8 0 / 13.0

# Verdict Execution time Memory Grader output
1 Runtime error 37 ms 13396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -