Submission #1127781

#TimeUsernameProblemLanguageResultExecution timeMemory
1127781VinhLuuFood Court (JOI21_foodcourt)C++20
7 / 100
62 ms14408 KiB
#include <bits/stdc++.h> #define ll long long #define all(lpv) lpv.begin(), lpv.end() #define pot(x, y) lower_bound(x.begin(), x.end(), y) - x.begin() + 1 using namespace std; #define lpv #ifndef lpv #include "AC.h" #endif // lpv #define int long long const int N = 2e5 + 5; int n, m, q, T[N], L[N], R[N], C[N], K[N], sz[N]; namespace sub1 { deque<pair<int,int>> dq[2002]; void solve() { for(int i = 1; i <= q; i ++) { if(T[i] == 1) { for(int j = L[i]; j <= R[i]; j ++) { dq[j].push_back({C[i], K[i]}); sz[j] += K[i]; } } else if (T[i] == 2) { for(int j = L[i]; j <= R[i]; j ++) { int cnt = K[i]; sz[j] = max(0ll, sz[j] - K[i]); while(!dq[j].empty() && cnt != 0) { if(dq[j].front().second <= cnt) { cnt -= dq[j].front().second; dq[j].pop_front(); } else { int x, y; tie(x, y) = dq[j].front(); dq[j].pop_front(); dq[j].push_front({x, y - cnt}); cnt = 0; } } } } else { // cerr << L[i] << " " << dq[L[i]].size() << " g\n"; if(sz[L[i]] < R[i]) cout << 0 << "\n"; else { int cnt = R[i]; for(auto [x, y] : dq[L[i]]) { if(cnt <= y) { cout << x << "\n"; break; } else cnt -= y; } } } } } } #ifdef lpv signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" if(fopen(task ".inp","r")) { freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } cin >> n >> m >> q; for(int i = 1; i <= q; i ++) { cin >> T[i]; if(T[i] == 1) cin >> L[i] >> R[i] >> C[i] >> K[i]; else if(T[i] == 2) cin >> L[i] >> R[i] >> K[i]; else cin >> L[i] >> R[i]; } sub1 :: solve(); } #endif // lpv

Compilation message (stderr)

foodcourt.cpp: In function 'int main()':
foodcourt.cpp:68:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     freopen(task ".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:69:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     freopen(task ".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...