Submission #65217

#TimeUsernameProblemLanguageResultExecution timeMemory
65217TalantTeams (IOI15_teams)C++17
21 / 100
4054 ms35944 KiB
#include "teams.h" //#include "grader.cpp" #include <bits/stdc++.h> #define mk make_pair #define sc second #define fr first #define pb push_back using namespace std; const int NN = (1e6 + 5); const int inf = (1e9 + 7); int n,m; int a[NN],b[NN]; int k[NN]; int u[NN]; deque <pair<int,int> > v; void init(int N, int A[], int B[]) { n = N; for (int i = 0; i < n; i ++) { a[i] = A[i],b[i] = B[i]; } } int can(int M, int K[]) { int m = M; v.clear(); for (int i = 0; i < m; i ++) k[i] = K[i]; sort (k,k + m); for (int i = 0; i < n; i ++) v.pb(mk(b[i],a[i])); sort (v.begin(),v.end()); for (int i = 0; i < m; i ++) { int cn = 0; deque<pair<int,int> > dq; dq.clear(); while (!v.empty()) { if (v.front().fr >= k[i] && v.front().sc <= k[i]) cn ++,v.pop_front(); else { if (v.front().fr <= k[i]) v.pop_front(); else { dq.pb(v.front()); v.pop_front(); } } if (cn == k[i]) break; } if (cn != k[i]) return 0; v.swap(dq); for (auto to : dq) v.pb(to); } return 1; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:32:11: warning: declaration of 'm' shadows a global declaration [-Wshadow]
       int m = M;
           ^
teams.cpp:16:7: note: shadowed declaration is here
 int n,m;
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...