Submission #286290

#TimeUsernameProblemLanguageResultExecution timeMemory
286290DystoriaXTeams (IOI15_teams)C++14
0 / 100
58 ms16364 KiB
#include "teams.h" #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <bitset> // #include <numeric> using namespace std; int n; int prefix[500010], suffix[500010]; vector<pair<int, int> > pt; void init(int N, int A[], int B[]) { n = N; for(int i = 0; i < n; i++){ prefix[B[i]]++; suffix[A[i]]++; } for(int i = 1; i <= n; i++) prefix[i] += prefix[i - 1]; for(int i = n - 1; i; i--) suffix[i] += suffix[i + 1]; } int can(int M, int K[]) { long long sum = 0; for(int i = 0; i < M; i++) sum += K[i]; if(sum > n) return 0; sort(K, K + M); pt.clear(); int cnt = K[0]; for(int i = 1; i < M; i++){ if(K[i] != K[i - 1]){ pt.emplace_back(K[i - 1], cnt); cnt = K[i]; } else { cnt += K[i]; } } pt.emplace_back(K[M - 1], cnt); int dp = 0, mn = 0; for(int i = 0; i < (int) pt.size(); i++){ pair<int, int> k = pt[i]; dp = n - suffix[k.first + 1] - k.second + mn; if(dp < 0) return 0; if(i < (int) pt.size() - 1) mn = min(mn, dp + prefix[pt[i + 1].first - 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...