Submission #587978

#TimeUsernameProblemLanguageResultExecution timeMemory
587978MadokaMagicaFanDistributing Candies (IOI21_candies)C++17
3 / 100
5058 ms12916 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; const ll inf = 1e9; const int md1 = 1e9+7; const int md2 = 998244353; #define sz(v) ((int)v.size()) #define pb push_back #define pry cout << "YES\n" #define prn cout << "NO\n" #define endl '\n' #define fst first #define scn second /* #define ONPC */ using vi = vector<int>; vi sub1(vi &c, vi &l, vi &r, vi &v) { int n = sz(c); int q = sz(l); vi ans; ll val; for (int i = 0; i < n; ++i) { val = 0; for (int j = 0; j < q; ++j) { if (i < l[j] || i > r[j]) continue; val += (ll)v[j]; val = min(val,(ll)c[i]); val = max(val,0ll); } ans.pb(val); } return ans; } vi distribute_candies(vi c, vi l, vi r, vi v) { int n = sz(c); int q = sz(l); if (n < 3e5 && q < 3e5) return sub1(c,l,r,v); vi tans; for (int i = 0; i < n; ++i) tans.pb(69); return tans; } #ifdef ONPC void solve() { int n, q; cin >> n >> q; vector<int> c(n); for (int i = 0; i < n; ++i) cin >> c[i]; vector<int> l(q), r(q), v(q); for (int i = 0; i < q; ++i) cin >> l[i] >> r[i] >> v[i]; vi ans = distribute_candies(c,l,r,v); for (int i = 0; i < sz(ans); ++i) { cout << ans[i] << ' '; } cout << endl; } int32_t main(int argc, char **argv) { if (argc >= 2) { freopen(argv[1], "r", stdin); } else ios_base::sync_with_stdio(0);cin.tie(0); int t = 1; /* cin >> t; */ while(t--) solve(); } #endif
#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...