Submission #841907

#TimeUsernameProblemLanguageResultExecution timeMemory
841907SUNWOOOOOOOOPassport (JOI23_passport)C++17
0 / 100
0 ms348 KiB
#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 (stderr)

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);
      |                                     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...