Submission #131385

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

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