Submission #222004

#TimeUsernameProblemLanguageResultExecution timeMemory
222004Mamnoon_SiamTeams (IOI15_teams)C++11
0 / 100
4086 ms11896 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; 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 count(int l, int r) { int ret = 0; for(int i = 0; i < N; ++i) { ret += l <= A[i] and B[i] <= r; } return ret; } int can(int M, int K[]) { for(ll i = 0, s = 0; i < M; ++i) { if((s += K[i]) > N) return 0; } map<int, int> cnt; for(int i = 0; i < M; ++i) { cnt[K[i]] += K[i]; } vector<ii> v; for(auto x : cnt) { v.emplace_back(x.first, x.second); } for(int i = 0; i < (int)v.size(); ++i) { int s = 0, exc = 0; for(int j = i; j < (int)v.size(); ++j) { s += v[j].second; if(i < j) exc += count(v[j-1].first+1, v[j].first-1); if(N - count(1, v[i].first-1) - exc - count(v[j].first+1, N) < s) { return 0; } } } 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...