Submission #559244

#TimeUsernameProblemLanguageResultExecution timeMemory
559244AriaHTeams (IOI15_teams)C++17
0 / 100
75 ms14716 KiB
#include "teams.h" #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair < int, int > pii; typedef pair < ll, ll > pll; #define F first #define S second #define all(x) x.begin(), x.end() #define SZ(x) (int)x.size() #define Mp make_pair #define endl "\n" #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); const int N = 5e5 + 10; const int LOG = 20; const ll mod = 1e9 + 7; const ll inf = 8e18; int n, pre[N], suf[N]; ll ps[N]; void init(int _n, int A[], int B[]) { n = _n; for(int i = 0; i < n; i ++) { pre[B[i]] ++; suf[A[i]] ++; } for(int i = 1; i <= n + 1; i ++) { pre[i] += pre[i - 1]; } for(int i = n + 1; i >= 0; i --) { suf[i] += suf[i + 1]; } /*for(int i = 1; i <= n; i ++) { printf("i = %d pre = %d suf = %d\n", i, pre[i], suf[i]); } */ } int can(int m, int arr[]) { sort(arr, arr + m); ll sum = 0, Best = 0; for(int i = 0; i < m; i ++) { sum += arr[i]; if(sum > n) return 0; ll now = sum + suf[arr[i] + 1] + Best; ///printf("i = %d sum = %lld Best = %lld now = %lld\n", i, sum, Best, now); if(now > n) return 0; Best = max(Best, -sum + pre[arr[i] - 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...