제출 #414208

#제출 시각아이디문제언어결과실행 시간메모리
414208ja_kingy팀들 (IOI15_teams)C++14
34 / 100
4067 ms14284 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; const int X = 700; vector<pii> order, buckets[X]; #define r first #define l second void init(int N, int A[], int B[]) { for (int i = 0; i < N; ++i) { order.push_back({B[i], A[i]}); } sort(order.begin(), order.end()); for (pii p: order) buckets[min(p.r,X-1)].push_back({p.r, p.l}); } int can(int M, int K[]) { int sm = accumulate(K, K+M, 0), lft = 0; vector<int> ks(K, K+M); sort(ks.begin(), ks.end(), greater<int>()); map<int, int> req; if (sm < X) { for (int r = 1; r < X; ++r) { while (ks.size() && ks.back() <= r) { lft = ks.back(); req[ks.back()] += ks.back(); ks.pop_back(); } for (pii p: buckets[r]) { if (p.l <= lft) { auto it = req.lower_bound(p.l); it->second--; if (it->second == 0) req.erase(it); lft = req.size() ? (--req.end())->first : 0; } else break; } } } else { for (pii p: order) { while (ks.size() && ks.back() <= p.r) { lft = ks.back(); req[ks.back()] += ks.back(); ks.pop_back(); } if (req.size() && p.l <= (--req.end())->first) { if (p.l <= lft) { auto it = req.lower_bound(p.l); it->second--; if (it->second == 0) req.erase(it); lft = req.size() ? (--req.end())->first : 0; } else break; } } } return req.size() == 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...