Submission #1140311

#TimeUsernameProblemLanguageResultExecution timeMemory
1140311efishelTeams (IOI15_teams)C++20
0 / 100
4094 ms42072 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector <ll>; using ii = pair <ll, ll>; using vii = vector <ii>; ll n; vll vl, vr; // vll ve; void init (int n, int aa[], int bb[]) { ::n = n; vl = vll(aa, aa+n); vr = vll(bb, bb+n); } int can (int m, int k[]) { vll th(k, k+m); // sort(th.begin(), th.end()); vector <vll> ls(n+1); for (ll i = 0; i < n; i++) { ls[vl[i]].push_back(vr[i]); } multiset <ll> mst; vll freq(n+1, 0); for (ll i : th) freq[i]++; for (ll i = 1; i <= n; i++) { for (ll rs : ls[i]) mst.insert(rs); if (mst.size() < freq[i]*i) return 0; while (freq[i]--) { for (ll j = 0; j < i; j++) { assert(mst.size()); mst.erase(mst.begin()); } } while (mst.size() && *mst.rbegin() < i) mst.erase(mst.find(*mst.rbegin())); } 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...