제출 #1128526

#제출 시각아이디문제언어결과실행 시간메모리
1128526nhanhoang510Triangle Collection (CCO23_day2problem3)C++20
0 / 25
24 ms464 KiB
#include <bits/stdc++.h> #define F first #define S second using namespace std; const int maxn = 2 * 1e5 + 7; const int LOG = 20; const long long MOD = (long long)(1e9) + 7; const long long base = 311; const int ALP_BET = 26; typedef pair<int, int> ii; typedef pair<int, long long> il; typedef pair<long long, int> li; typedef pair<long long, long long> ll; int n, q; long long a[maxn]; long long solve(){ long long res = 0; int id = 1; for(int i = 1; i <= n; ++i){ while(a[i] / 2LL > 0LL && id != i){ long long mins = min(a[id], a[i] / 2LL); a[id] = a[id] - mins; a[i] = a[i] - mins * 2LL; res = res + mins; if(a[id] == 0) ++id; } } for(int i = 1; i <= n; ++i) res = res + a[i] / 3LL; return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("Triangl.INP","r",stdin); // freopen("Triangl.OUT","w",stdout); cin >> n >> q; for(int i = 1; i <= n; ++i) cin >> a[i]; while(q--){ int l, d; cin >> l >> d; a[l] = a[l] + 1LL * d; long long ans = solve(); cout << ans << "\n"; } return 0; }
#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...