Submission #430873

#TimeUsernameProblemLanguageResultExecution timeMemory
430873p_squareTeams (IOI15_teams)C++14
34 / 100
4066 ms8480 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define mp make_pair #define fi first #define se second #define pb push_back vector<pii> stud; int n; struct cmp { bool operator()(pii a, pii b) { if(a.fi != b.fi) return a.fi > b.fi; return a.fi > b.fi; } }; void init(int N, int A[], int B[]) { n = N; for(int i = 0; i<n; i++) { stud.pb(mp(A[i], B[i])); } sort(stud.begin(), stud.end(), cmp()); } int can(int M, int K[]) { sort(K, K+M); vector<pii> need; int dsleft[M]; need.pb(mp(K[M-1], K[M-1])); int ct = 0; for(int i = 1; i<M; i++) { if(K[M-i-1] != need[ct].fi) { ct++; need.pb(mp(K[M-1-i], K[M-1-i])); } else { need[ct].se += K[M-i-1]; } dsleft[i] = i; } M = ct+1; int sum; for(int i = 0; i<n; i++) { //cout<<stud[i].fi<<" "<<stud[i].se<<endl; for(int j = 0; j<M; j++) { if(need[j].se == 0) continue; if(stud[i].fi <= need[j].fi && need[j].fi <= stud[i].se) { need[j].se--; break; } } } int ans = 1; for(int i = 0; i<M; i++) { if(need[i].se != 0) ans = 0; } return ans; }

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:40:9: warning: variable 'dsleft' set but not used [-Wunused-but-set-variable]
   40 |     int dsleft[M];
      |         ^~~~~~
teams.cpp:57:9: warning: unused variable 'sum' [-Wunused-variable]
   57 |     int sum;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...