Submission #94809

#TimeUsernameProblemLanguageResultExecution timeMemory
94809someone_aaTeams (IOI15_teams)C++17
34 / 100
4027 ms20836 KiB
#include <bits/stdc++.h> #include "teams.h" #define P pair<int,int> #define pb push_back #define ll long long #define mp make_pair using namespace std; int n; vector<P>intervals; bool compare(P a, P b) { if(a.second == b.second) return a.first > b.first; else return a.second < b.second; } void init(int N, int A[], int B[]) { n = N; for(int i=0;i<N;i++) { intervals.pb(mp(A[i], B[i])); } sort(intervals.begin(), intervals.end(), compare); } int OK[500100]; bool visited[500100]; int ln[500100], rn[500100]; int can(int M, int K[]) { sort(K, K + M); ll sum = 0LL; for(int i=0;i<M;i++) { OK[i] = K[i]; sum += 1LL * K[i]; } if(sum > n) return 0; for(int i=0;i<n;i++) { visited[i] = false; } for(int i=0;i<n;i++) { ln[i] = i-1; rn[i] = i+1; } rn[n-1] = -1; int taken = 0; int st = 0; int br = 0; for(int p=0;p<M;p++) { int j = st; int taken = 0; while(j != -1) { if(intervals[j].first <= K[p] && intervals[j].second >= K[p]) { taken++; rn[ln[j]] = rn[j]; ln[rn[j]] = ln[j]; if(j == st) { j = rn[j]; st = j; } else j = rn[j]; if(taken == K[p]) { br++; break; } } else j = rn[j]; } if(taken != K[p]) break; } return bool(br == M); }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:52:13: warning: declaration of 'taken' shadows a previous local [-Wshadow]
         int taken = 0;
             ^~~~~
teams.cpp:47:9: note: shadowed declaration is here
     int taken = 0;
         ^~~~~
teams.cpp:47:9: warning: unused variable 'taken' [-Wunused-variable]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...