답안 #557546

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
557546 2022-05-05T12:56:07 Z 600Mihnea 푸드 코트 (JOI21_foodcourt) C++17
2 / 100
1000 ms 17960 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<ll>> questions;
  vector<int> sol;

  for (int i=1;i<=q;i++) {
    int type;
    cin>>type;
    assert(1<=type&&type<=3);
    questions.push_back(vector<ll> (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];
        ll 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);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 340 KB Output is correct
2 Correct 17 ms 464 KB Output is correct
3 Correct 13 ms 432 KB Output is correct
4 Correct 20 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 21 ms 460 KB Output is correct
8 Correct 20 ms 476 KB Output is correct
9 Correct 19 ms 480 KB Output is correct
10 Correct 20 ms 468 KB Output is correct
11 Correct 21 ms 472 KB Output is correct
12 Correct 19 ms 476 KB Output is correct
13 Correct 15 ms 452 KB Output is correct
14 Correct 21 ms 468 KB Output is correct
15 Correct 14 ms 428 KB Output is correct
16 Correct 23 ms 468 KB Output is correct
17 Correct 12 ms 444 KB Output is correct
18 Correct 19 ms 468 KB Output is correct
19 Correct 10 ms 448 KB Output is correct
20 Correct 12 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 340 KB Output is correct
2 Correct 17 ms 464 KB Output is correct
3 Correct 13 ms 432 KB Output is correct
4 Correct 20 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 21 ms 460 KB Output is correct
8 Correct 20 ms 476 KB Output is correct
9 Correct 19 ms 480 KB Output is correct
10 Correct 20 ms 468 KB Output is correct
11 Correct 21 ms 472 KB Output is correct
12 Correct 19 ms 476 KB Output is correct
13 Correct 15 ms 452 KB Output is correct
14 Correct 21 ms 468 KB Output is correct
15 Correct 14 ms 428 KB Output is correct
16 Correct 23 ms 468 KB Output is correct
17 Correct 12 ms 444 KB Output is correct
18 Correct 19 ms 468 KB Output is correct
19 Correct 10 ms 448 KB Output is correct
20 Correct 12 ms 468 KB Output is correct
21 Incorrect 15 ms 468 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 4232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 17960 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 340 KB Output is correct
2 Correct 17 ms 464 KB Output is correct
3 Correct 13 ms 432 KB Output is correct
4 Correct 20 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 21 ms 460 KB Output is correct
8 Correct 20 ms 476 KB Output is correct
9 Correct 19 ms 480 KB Output is correct
10 Correct 20 ms 468 KB Output is correct
11 Correct 21 ms 472 KB Output is correct
12 Correct 19 ms 476 KB Output is correct
13 Correct 15 ms 452 KB Output is correct
14 Correct 21 ms 468 KB Output is correct
15 Correct 14 ms 428 KB Output is correct
16 Correct 23 ms 468 KB Output is correct
17 Correct 12 ms 444 KB Output is correct
18 Correct 19 ms 468 KB Output is correct
19 Correct 10 ms 448 KB Output is correct
20 Correct 12 ms 468 KB Output is correct
21 Execution timed out 1084 ms 4232 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1034 ms 5572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 340 KB Output is correct
2 Correct 17 ms 464 KB Output is correct
3 Correct 13 ms 432 KB Output is correct
4 Correct 20 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 21 ms 460 KB Output is correct
8 Correct 20 ms 476 KB Output is correct
9 Correct 19 ms 480 KB Output is correct
10 Correct 20 ms 468 KB Output is correct
11 Correct 21 ms 472 KB Output is correct
12 Correct 19 ms 476 KB Output is correct
13 Correct 15 ms 452 KB Output is correct
14 Correct 21 ms 468 KB Output is correct
15 Correct 14 ms 428 KB Output is correct
16 Correct 23 ms 468 KB Output is correct
17 Correct 12 ms 444 KB Output is correct
18 Correct 19 ms 468 KB Output is correct
19 Correct 10 ms 448 KB Output is correct
20 Correct 12 ms 468 KB Output is correct
21 Incorrect 15 ms 468 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 340 KB Output is correct
2 Correct 17 ms 464 KB Output is correct
3 Correct 13 ms 432 KB Output is correct
4 Correct 20 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 21 ms 460 KB Output is correct
8 Correct 20 ms 476 KB Output is correct
9 Correct 19 ms 480 KB Output is correct
10 Correct 20 ms 468 KB Output is correct
11 Correct 21 ms 472 KB Output is correct
12 Correct 19 ms 476 KB Output is correct
13 Correct 15 ms 452 KB Output is correct
14 Correct 21 ms 468 KB Output is correct
15 Correct 14 ms 428 KB Output is correct
16 Correct 23 ms 468 KB Output is correct
17 Correct 12 ms 444 KB Output is correct
18 Correct 19 ms 468 KB Output is correct
19 Correct 10 ms 448 KB Output is correct
20 Correct 12 ms 468 KB Output is correct
21 Incorrect 15 ms 468 KB Output isn't correct
22 Halted 0 ms 0 KB -