# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
496274 |
2021-12-21T04:38:53 Z |
Ziel |
Meteors (POI11_met) |
C++17 |
|
6000 ms |
21316 KB |
/**
* LES GREATEABLES BRO TEAM
**/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(x) (int)x.size()
const bool FLAG = false;
void setIO(const string &f = "");
#define int ll
const int N = 5e5 + 13;
int t[4 * N], u[4 * N];
void push(int x, int lx, int rx) {
if (u[x]) {
int mid = (lx + rx) / 2;
t[2 * x + 1] += u[x] * (mid - lx + 1);
t[2 * x + 2] += u[x] * (rx - mid + 1);
u[2 * x + 1] += u[x];
u[2 * x + 2] += u[x];
u[x] = 0;
}
}
void upd(int l, int r, int v, int x, int lx, int rx) {
if (r < lx || rx < l) return;
if (l <= lx && rx <= r) {
t[x] += v * (rx - lx + 1);
u[x] += v;
return;
}
push(x, lx, rx);
int mid = (lx + rx) / 2;
upd(l, r, v, 2 * x + 1, lx, mid);
upd(l, r, v, 2 * x + 2, mid + 1, rx);
t[x] = t[2 * x + 1] + t[2 * x + 2];
}
int get(int i, int x, int lx, int rx) {
if (rx == lx)
return t[x];
push(x, lx, rx);
int mid = (lx + rx) / 2;
if (i <= mid)
return get(i, 2 * x + 1, lx, mid);
else
return get(i, 2 * x + 2, mid + 1, rx);
}
void solve() {
int n, m;
cin >> n >> m;
vector<int> o(m + 1);
for (int i = 1; i <= m; i++)
cin >> o[i];
vector<int> p(n + 1);
for (int i = 1; i <= n; i++)
cin >> p[i];
int q;
cin >> q;
vector<int> ans(n + 1);
for (int rep = 1; rep <= q; rep++) {
int l, r, x;
cin >> l >> r >> x;
if (l <= r)
upd(l, r, x, 0, 1, m);
else {
upd(l, m, x, 0, 1, m);
upd(1, r, x, 0, 1, m);
}
vector<int> _p = p;
for (int i = 1; i <= m; i++) {
p[o[i]] -= get(i, 0, 1, m);
if (p[o[i]] <= 0 && !ans[o[i]])
ans[o[i]] = rep;
}
p = _p;
}
for (int i = 1; i <= n; i++) {
if (!ans[i])
cout << "NIE\n";
else
cout << ans[i] << '\n';
}
}
signed main() {
setIO();
int tt = 1;
if (FLAG) {
cin >> tt;
}
while (tt--) {
solve();
}
return 0;
}
void setIO(const string &f) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen((f + ".in").c_str(), "r")) {
freopen((f + ".in").c_str(), "r", stdin);
freopen((f + ".out").c_str(), "w", stdout);
}
}
Compilation message
met.cpp: In function 'void setIO(const string&)':
met.cpp:108:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
108 | freopen((f + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
met.cpp:109:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
109 | freopen((f + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
59 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6094 ms |
2856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6078 ms |
3044 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6089 ms |
896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6067 ms |
2764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6098 ms |
21316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6072 ms |
21100 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |