Submission #911336

#TimeUsernameProblemLanguageResultExecution timeMemory
911336denniskimCake 3 (JOI19_cake3)C++17
0 / 100
4 ms600 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef __int128 lll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ld, ld> pld; #define MAX 9223372036854775807LL #define MIN -9223372036854775807LL #define INF 0x3f3f3f3f3f3f3f3f #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10); #define sp << " " #define en << "\n" #define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end()) struct gujo { ll V, C; bool operator < (const gujo &xx) const { return C < xx.C; } }; ll n, m; gujo a[200010]; ll ans; ll last = -1; int main(void) { fastio cin >> n >> m; for(ll i = 1 ; i <= n ; i++) cin >> a[i].V >> a[i].C; sort(a + 1, a + 1 + n); for(ll i = m ; i <= n ; i++) { ll idx = -1, maxx = -INF; for(ll j = 1 ; j <= i - m + 1 ; j++) { ll sum = a[j].V + 2 * a[j].C + a[i].V - 2 * a[i].C; vector<ll> gap; for(ll k = j + 1 ; k < i ; k++) gap.push_back(a[k].V); sort(gap.begin(), gap.end()); for(ll k = 0 ; k < m - 2 ; k++) sum += gap[(ll)gap.size() - 1 - k]; if(maxx < sum) { maxx = sum; idx = j; } } ans = max(ans, maxx); if(last > idx) assert(0); last = idx; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...