답안 #841907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
841907 2023-09-02T08:19:44 Z SUNWOOOOOOOO Passport (JOI23_passport) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = 200005;
int n, q, l[mxN], r[mxN];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d %d", &l[i], &r[i]);
    scanf("%d", &q);
    for (int i = 1, a; i <= q; i++) scanf("%d", &a);

    int ans = 0, cur = 0, nxt = 0;
    for (int i = 1; i <= n; i++){
        nxt = max(nxt, r[i]);
        if (i > cur){
            ans++;
            cur = nxt;
            nxt = r[i];
        }
    }

    if (cur == n) printf("%d\n", ans);
    else printf("-1\n");

    return 0;
}

Compilation message

passport.cpp: In function 'int main()':
passport.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
passport.cpp:9:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     for (int i = 1; i <= n; i++) scanf("%d %d", &l[i], &r[i]);
      |                                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
passport.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
passport.cpp:11:42: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for (int i = 1, a; i <= q; i++) scanf("%d", &a);
      |                                     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -