# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1014646 |
2024-07-05T08:49:49 Z |
Whisper |
Meteors (POI11_met) |
C++17 |
|
377 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPD(i, n) for (int i = (n) - 1; i >= 0; --i)
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*
Phu Trong from Nguyen Tat Thanh High School for gifted student
*/
template <class X, class Y>
bool minimize(X &x, const Y &y){
X eps = 1e-9;
if (x > y + eps) {x = y; return 1;}
return 0;
}
template <class X, class Y>
bool maximize(X &x, const Y &y){
X eps = 1e-9;
if (x + eps < y) {x = y; return 1;}
return 0;
}
#define MAX 300005
int N, M, numQuery;
int target[MAX];
vector<int> station[MAX];
int L[MAX], R[MAX], G[MAX];
int ans[MAX];
int F[MAX];
void upd(int p, int val){
for (; p <= M; p += p & (-p)) F[p] += val;
}
void upd(int l, int r, int v) {
upd(r + 1, -v), upd(l, v);
if (l > r)
upd(1, v), upd(M + 1, -v);
}
int query(int p){
int res = 0;
for (; p > 0; p -= p & (-p)) res += F[p];
return res;
}
void parallel(int l, int r, vector<int>&cand){
if (l + 1 == r || cand.empty()){
for (int&i : cand) ans[i] = l;
return;
}
int m = (l + r) >> 1;
for (int i = l; i < m; ++i){
upd(L[i], R[i], G[i]);
}
vector<int> ok, not_ok;
for (int &i : cand){
int sum = 0;
bool ahihi = 0;
for (int &pos : station[i]){
sum += query(pos);
if (sum >= target[i]) {
ahihi = 1;
}
}
if (ahihi) ok.push_back(i);
else {
target[i] -= sum;
not_ok.push_back(i);
}
}
for (int i = l; i < m; ++i){
upd(L[i], R[i], -G[i]);
}
parallel(l, m, ok);
parallel(m, r, not_ok);
}
void process(void){
cin >> N >> M;
for (int i = 1; i <= M; ++i){
int x; cin >> x;
station[x].emplace_back(i);
}
for (int i = 1; i <= N; ++i) cin >> target[i];
cin >> numQuery;
for (int i = 0; i < numQuery; ++i){
cin >> L[i] >> R[i] >> G[i];
}
vector<int> cand;
for (int i = 1; i <= M; ++i) cand.push_back(i);
parallel(0, numQuery + 1, cand);
for (int i = 1; i <= N; ++i){
if(ans[i] == numQuery) cout << "NIE\n";
else cout << ans[i] + 1 << '\n';
}
}
signed main(){
#define name "Whisper"
cin.tie(nullptr) -> sync_with_stdio(false);
//freopen(name".inp", "r", stdin);
//freopen(name".out", "w", stdout);
process();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7512 KB |
Output is correct |
2 |
Correct |
4 ms |
7516 KB |
Output is correct |
3 |
Correct |
4 ms |
7516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7516 KB |
Output is correct |
2 |
Correct |
4 ms |
7532 KB |
Output is correct |
3 |
Correct |
4 ms |
7540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
17932 KB |
Output is correct |
2 |
Correct |
69 ms |
18696 KB |
Output is correct |
3 |
Correct |
65 ms |
17356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
17792 KB |
Output is correct |
2 |
Correct |
71 ms |
17868 KB |
Output is correct |
3 |
Correct |
52 ms |
16324 KB |
Output is correct |
4 |
Correct |
21 ms |
15312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
17664 KB |
Output is correct |
2 |
Correct |
56 ms |
17876 KB |
Output is correct |
3 |
Correct |
16 ms |
9308 KB |
Output is correct |
4 |
Correct |
62 ms |
17104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
17912 KB |
Output is correct |
2 |
Correct |
74 ms |
17800 KB |
Output is correct |
3 |
Correct |
41 ms |
17992 KB |
Output is correct |
4 |
Correct |
79 ms |
17016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
337 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
377 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |