Submission #131391

#TimeUsernameProblemLanguageResultExecution timeMemory
131391antimirageTeams (IOI15_teams)C++14
0 / 100
4025 ms10744 KiB
#include "teams.h" #include <bits/stdc++.h> #define fr first #define sc second using namespace std; const int N = 1e5 + 5; int cn[N], n; pair <int, int> a[N]; void init(int N, int l[], int r[]) { n = N; for (int i = 0; i < n; i++) { a[i] = {r[i], l[i]}; } sort(a, a + n); } int can(int m, int k[]) { sort(k, k + m); int j = 0; priority_queue <pair <int, int> > q; for (int i = 0; i < m; i++) { int cn = k[i]; while (j < n && cn > 0) { q.push({-a[j].sc, a[j].fr}); while (!q.empty() && q.top().sc < k[i]) q.pop(); if (!q.empty() && -q.top().fr <= k[i]) { cn--; q.pop(); } j++; } while (!q.empty() && cn > 0 && -q.top().fr <= k[i]) { cn--; q.pop(); } if (j == n && cn > 0) return false; } return true; }

Compilation message (stderr)

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:15:34: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 void init(int N, int l[], int r[]) {
                                  ^
teams.cpp:9:11: note: shadowed declaration is here
 const int N = 1e5 + 5;
           ^
teams.cpp: In function 'int can(int, int*)':
teams.cpp:29:7: warning: declaration of 'cn' shadows a global declaration [-Wshadow]
   int cn = k[i];
       ^~
teams.cpp:11:5: note: shadowed declaration is here
 int cn[N], n;
     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...