Submission #557545

# Submission time Handle Problem Language Result Execution time Memory
557545 2022-05-05T12:55:05 Z 600Mihnea Food Court (JOI21_foodcourt) C++17
2 / 100
1000 ms 13768 KB
#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

foodcourt.cpp: In function 'int main()':
foodcourt.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("I_am_iron_man", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 20 ms 396 KB Output is correct
3 Correct 13 ms 460 KB Output is correct
4 Correct 20 ms 496 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 21 ms 600 KB Output is correct
8 Correct 24 ms 468 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 18 ms 480 KB Output is correct
11 Correct 18 ms 460 KB Output is correct
12 Correct 17 ms 460 KB Output is correct
13 Correct 14 ms 464 KB Output is correct
14 Correct 20 ms 476 KB Output is correct
15 Correct 13 ms 340 KB Output is correct
16 Correct 20 ms 496 KB Output is correct
17 Correct 11 ms 340 KB Output is correct
18 Correct 18 ms 468 KB Output is correct
19 Correct 8 ms 340 KB Output is correct
20 Correct 12 ms 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 20 ms 396 KB Output is correct
3 Correct 13 ms 460 KB Output is correct
4 Correct 20 ms 496 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 21 ms 600 KB Output is correct
8 Correct 24 ms 468 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 18 ms 480 KB Output is correct
11 Correct 18 ms 460 KB Output is correct
12 Correct 17 ms 460 KB Output is correct
13 Correct 14 ms 464 KB Output is correct
14 Correct 20 ms 476 KB Output is correct
15 Correct 13 ms 340 KB Output is correct
16 Correct 20 ms 496 KB Output is correct
17 Correct 11 ms 340 KB Output is correct
18 Correct 18 ms 468 KB Output is correct
19 Correct 8 ms 340 KB Output is correct
20 Correct 12 ms 472 KB Output is correct
21 Incorrect 7 ms 476 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 5136 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 13768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 20 ms 396 KB Output is correct
3 Correct 13 ms 460 KB Output is correct
4 Correct 20 ms 496 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 21 ms 600 KB Output is correct
8 Correct 24 ms 468 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 18 ms 480 KB Output is correct
11 Correct 18 ms 460 KB Output is correct
12 Correct 17 ms 460 KB Output is correct
13 Correct 14 ms 464 KB Output is correct
14 Correct 20 ms 476 KB Output is correct
15 Correct 13 ms 340 KB Output is correct
16 Correct 20 ms 496 KB Output is correct
17 Correct 11 ms 340 KB Output is correct
18 Correct 18 ms 468 KB Output is correct
19 Correct 8 ms 340 KB Output is correct
20 Correct 12 ms 472 KB Output is correct
21 Execution timed out 1084 ms 5136 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 3720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 20 ms 396 KB Output is correct
3 Correct 13 ms 460 KB Output is correct
4 Correct 20 ms 496 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 21 ms 600 KB Output is correct
8 Correct 24 ms 468 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 18 ms 480 KB Output is correct
11 Correct 18 ms 460 KB Output is correct
12 Correct 17 ms 460 KB Output is correct
13 Correct 14 ms 464 KB Output is correct
14 Correct 20 ms 476 KB Output is correct
15 Correct 13 ms 340 KB Output is correct
16 Correct 20 ms 496 KB Output is correct
17 Correct 11 ms 340 KB Output is correct
18 Correct 18 ms 468 KB Output is correct
19 Correct 8 ms 340 KB Output is correct
20 Correct 12 ms 472 KB Output is correct
21 Incorrect 7 ms 476 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 20 ms 396 KB Output is correct
3 Correct 13 ms 460 KB Output is correct
4 Correct 20 ms 496 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 21 ms 600 KB Output is correct
8 Correct 24 ms 468 KB Output is correct
9 Correct 20 ms 480 KB Output is correct
10 Correct 18 ms 480 KB Output is correct
11 Correct 18 ms 460 KB Output is correct
12 Correct 17 ms 460 KB Output is correct
13 Correct 14 ms 464 KB Output is correct
14 Correct 20 ms 476 KB Output is correct
15 Correct 13 ms 340 KB Output is correct
16 Correct 20 ms 496 KB Output is correct
17 Correct 11 ms 340 KB Output is correct
18 Correct 18 ms 468 KB Output is correct
19 Correct 8 ms 340 KB Output is correct
20 Correct 12 ms 472 KB Output is correct
21 Incorrect 7 ms 476 KB Output isn't correct
22 Halted 0 ms 0 KB -