제출 #1370375

#제출 시각아이디문제언어결과실행 시간메모리
1370375pirmyratgPassport (JOI23_passport)C++20
0 / 100
1 ms344 KiB
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    vector<int> l(n+1), r(n+1);
    for(int i = 1; i <= n; ++i)
        scanf("%d%d", &l[i], &r[i]);
    int Q;
    scanf("%d", &Q);
    assert(Q==1);
    int x;
    scanf("%d", &x);
    assert(x==1);
    int now=r[x], id=1, answer=1;
    while(id<=n){
        // printf("%d %d\n", now, id);
        if(id>now){
            puts("-1");
            return 0;
        }
        answer++;
        int mx=now;
        for(int i = id; i <= now; ++i)
            mx=max(mx, r[i]);
        now=mx, id=now+1;
    }
    printf("%d\n", answer);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

passport.cpp: In function 'int main()':
passport.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
passport.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         scanf("%d%d", &l[i], &r[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
passport.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d", &Q);
      |     ~~~~~^~~~~~~~~~
passport.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d", &x);
      |     ~~~~~^~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…