Submission #870028

#TimeUsernameProblemLanguageResultExecution timeMemory
870028LOLOLOMeteors (POI11_met)C++17
0 / 100
314 ms34120 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define f first #define s second #define pb push_back #define ep emplace #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin()) #define mem(f,x) memset(f , x , sizeof(f)) #define sz(x) (int)(x).size() #define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b)) #define mxx *max_element #define mnn *min_element #define cntbit(x) __builtin_popcountll(x) #define len(x) (int)(x.length()) const int N = 3e5 + 100; ll f[N]; int L[N], R[N], a[N], p[N], ans[N]; vector <int> on[N]; void upd(int i, int x) { for (; i < N; i += i & (-i)) f[i] += x; } ll get(int i) { ll s = 0; for (; i; i -= i & (-i)) s += f[i]; return s; } int cur = 0; void move(int m) { while (cur != m) { if (cur < m) { cur++; } else { cur--; } int x = a[cur]; if (L[cur] <= R[cur]) { upd(L[cur], x); upd(R[cur] + 1, -x); } else { upd(L[cur], x); upd(1, x); upd(R[cur] + 1, -x); } } } void dnc(int l, int r, vector <int>& lst) { if (l > r || lst.empty()) return; vector <int> win, lose; int m = (l + r) / 2; move(m); for (auto x : lst) { ll s = 0; for (auto t : on[x]) { s += get(t); } if (s >= p[x]) { ans[x] = m; win.pb(x); } else { lose.pb(x); } } lst.clear(); dnc(l, m - 1, win); dnc(m + 1, r, lose); } ll solve() { int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { int x; cin >> x; on[x].pb(i); } for (int i = 1; i <= n; i++) cin >> p[i]; int k; cin >> k; for (int i = 1; i <= k; i++) { cin >> L[i] >> R[i] >> a[i]; } vector <int> lst; for (int i = 1; i <= n; i++) lst.pb(i); dnc(1, k, lst); for (int i = 1; i <= n; i++) { if (ans[i] == 0) { cout << "NIE\n"; } else { cout << ans[i] << '\n'; } } return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; //cin >> t; while (t--) { solve(); //cout << solve() << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...