Submission #551597

#TimeUsernameProblemLanguageResultExecution timeMemory
551597tabrTeams (IOI15_teams)C++17
21 / 100
4045 ms8412 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif int n; vector<pair<int, int>> c; void init(int n_, int a[], int b[]) { n = n_; for (int i = 0; i < n; i++) { c.emplace_back(a[i], b[i]); } sort(c.begin(), c.end()); } int can(int m, int k[]) { if (accumulate(k, k + m, 0LL) > n) { return 0; } sort(k, k + m); vector<pair<int, int>> d; for (int i = 0, j = 0; i < m; i = j) { while (j < m && k[i] == k[j]) { j++; } d.emplace_back(k[i], j - i); } int sz = (int) d.size(); auto Solve = [&](int l, int r) { int res = 0; for (int i = 0; i < n; i++) { if (l <= c[i].first && c[i].second <= r) { res++; } } return res; }; vector<int> dp(sz); for (int i = 0; i < sz; i++) { dp[i] = Solve(1, d[i].first - 1); for (int j = 0; j < i; j++) { dp[i] = max(dp[i], dp[j] + Solve(d[j].first + 1, d[i].first - 1)); } dp[i] += d[i].first * d[i].second; } for (int i = 0; i < sz; i++) { dp[i] += Solve(d[i].first + 1, n); } if (*max_element(dp.begin(), dp.end()) > n) { return 0; } else { return 1; } } #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); return 0; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...