제출 #428366

#제출 시각아이디문제언어결과실행 시간메모리
428366egekabas카니발 티켓 (IOI20_tickets)C++14
41 / 100
771 ms53316 KiB
#include "tickets.h" #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<int> beg(n), fin(n), sum(n); for(int i = 0; i < n; ++i){ beg[i] = 0; fin[i] = m-1; for(int j = 0; j < m; ++j) sum[i] += x[i][j]; } vector<vector<int>> ret(n, vector<int>(m, -1)); ll ans = 0; for(int round = 0; round < k; ++round){ vector<pair<pii, int>> vec; for(int i = 0; i < n; ++i) vec.pb({{x[i][beg[i]] + x[i][fin[i]], sum[i]}, i}); sort(all(vec), greater<pair<pii, int>>()); for(int i = 0; i < n; ++i){ int idx = vec[i].ss; if(i < n/2){ ans += x[idx][fin[idx]]; ret[idx][fin[idx]] = round; sum[idx] -= x[idx][fin[idx]]; --fin[idx]; } else{ ans -= x[idx][beg[idx]]; ret[idx][beg[idx]] = round; sum[idx] -= x[idx][beg[idx]]; ++beg[idx]; } } } allocate_tickets(ret); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...