# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
557545 | 600Mihnea | Food Court (JOI21_foodcourt) | C++17 | 1086 ms | 13768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
bool home = 1;
using namespace std;
typedef long long ll;
int n,m,q;
signed main() {
#ifdef ONLINE_JUDGE
home = 0;
#endif
home=0;
if (home) {
freopen("I_am_iron_man", "r", stdin);
}
else {
ios::sync_with_stdio(0); cin.tie(0);
}
cin>>n>>m>>q;
vector<vector<int>> questions;
vector<int> sol;
for (int i=1;i<=q;i++) {
int type;
cin>>type;
assert(1<=type&&type<=3);
questions.push_back(vector<int>(5-type));
if(type==3)sol.push_back(-1);
for (auto &qu:questions.back()) cin>>qu;
}
for(int i=1;i<=n;i++) {
vector<pair<ll, int>> ev;
int have=0;
int jump=0;
int id=-1;
for (auto &question:questions) {
int type=5-(int)question.size();
assert(1<=type&&type<=3);
id+=(type==3);
if(type==1) {
int l=question[0],r=question[1],group=question[2],k=question[3];
if(l<=i&&i<=r) {
have+=k;
ev.push_back({have, group});
}
}
if (type==2) {
int l=question[0],r=question[1],k=question[2];
if (l<=i&&i<=r) {
jump=min(have,jump+k);
}
}
if(type==3) {
int a=question[0],b=question[1];
if (a==i) {
b+=jump;
if (b>have) {
sol[id]=0;
}else{
int low=0,high=(int) ev.size()-1,pz=-1;
while (low<=high) {
int mid=(low+high)/2;
if(ev[mid].first>=b) {
pz=mid;
high=mid-1;
}else{
low=mid+1;
}
}
assert(pz!=-1);
sol[id]=ev[pz].second;
}
}
}
}
}
for (auto &x:sol) {
cout<<x<<"\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |