Submission #991809

#TimeUsernameProblemLanguageResultExecution timeMemory
991809n3rm1nFood Court (JOI21_foodcourt)C++17
7 / 100
1050 ms524288 KiB
#include<bits/stdc++.h> #define endl '\n' #define ll long long using namespace std; const long long MAXN = 7e4+10; void speed() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } long long n, m, q; long long t[MAXN * 4]; vector < pair < long long/**number*/, long long/**colour*/> > g[MAXN]; vector < long long > pref[MAXN]; long long cutted[MAXN]; void solve() { cin >> n >> m >> q; long long type, l, r, k, c; for (long long i = 1; i <= n; ++ i) { pref[i].push_back(0); g[i].push_back({0, 0}); } long long aa, bb; for (long long i = 1; i <= q; ++ i) { cin >> type; if(type == 1) { cin >> l >> r >> c >> k; for (long long j = l; j <= r; ++ j) { g[j].push_back(make_pair(k, c)); pref[j].push_back(pref[j].back()+k); } } else if(type == 2) { cin >> l >> r >> k; for (long long j = l; j <= r; ++ j) cutted[j] += min(pref[j].back() - cutted[j], k); } else { cin >> aa >> bb; /// cout << "* " << cutted[aa] << " " << endl; long long l = 0, r = pref[aa].size()-1, mid, ans = 0; while(l <= r) { mid = (l + r)/2; if(pref[aa][mid] < bb + cutted[aa]) { l = mid + 1; } else { ans = mid; r = mid - 1; } } cout << g[aa][ans].second << endl; } } } int main() { speed(); solve(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...