Submission #223090

#TimeUsernameProblemLanguageResultExecution timeMemory
223090Mamnoon_SiamTeams (IOI15_teams)C++11
0 / 100
4086 ms27072 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ll = long long; using ii = pair<int, int>; const int maxn = 2e5 + 5; int A[maxn], B[maxn], N; vi g[maxn]; 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]; for(int i = 0; i < N; i++) { g[B[i]].push_back(A[i]); } } int can(int M, int K[]) { int k = N; for(ll i = 0, s = 0; i < M; ++i) { if((s += K[i]) > N) return 0; k -= K[i]; } vi cnt(N+1); for(int i = 0; i < M; ++i) { cnt[K[i]] += K[i]; } for(int i = 1; i <= N; ++i) { int x = 0, y = 0; for(int j = i; j <= N; ++j) { x += cnt[j]; for(int l : g[j]) { if(l >= i) ++y; } if(y-k > x) return 0; } } return 1; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...