제출 #431997

#제출 시각아이디문제언어결과실행 시간메모리
431997TryMax카니발 티켓 (IOI20_tickets)C++17
100 / 100
944 ms88544 KiB
#include "tickets.h" #ifdef LOCAL #include "grader.cpp" #endif // LOCAL #include <bits/stdc++.h> #define f first #define s second #define ll long long #define pb push_back using namespace std; const int N = 2e6 + 10; ll have[N], was[N], cnt[N], pl[N], pr[N]; ll find_maximum(int k, vector<vector<int>> x){ int n = x.size(); int m = x[0].size(); ll tans = 0; vector<pair<int, int>> t; for(int i = 0; i < n; ++i){ for(int j = m - 1; j >= m - k; --j) tans += x[i][j]; // cout << i << endl; for(int j = 0; j < k; ++j) t.pb({-x[i][m - k + j] - x[i][j], i}); } // cout << 1 << endl; sort(t.begin(), t.end(), greater<pair<int, int>>()); for(int i = 0; i < n * k / 2; ++i) ++cnt[t[i].s], tans += t[i].f; vector<int> t1; for(int i = 0; i < n; ++i) for(int j = 0; j < cnt[i]; ++j) t1.pb(i); vector<vector<int>> ans; ans.resize(n); for(int i = 0; i < n; ++i){ ans[i].resize(m); for(int j = 0; j < m; ++j) ans[i][j] = -1; } for(int i = 0; i < n; ++i) pl[i] = 0, pr[i] = m - 1; for(int i = 0; i < k; ++i){ for(int j = 0; j < n; ++j) was[j] = 0; for(int j = 0; j < n / 2; ++j) was[t1[i + k * j]] = 1, ans[t1[i + k * j]][pl[t1[i + k * j]]++] = i; for(int j = 0; j < n; ++j) if(was[j] == 0) ans[j][pr[j]--] = i; } allocate_tickets(ans); return tans; } /* 2 3 2 0 2 5 1 1 3 7 0 -1 1 -1 1 0 4 2 1 5 9 1 4 3 6 2 7 12 -1 0 0 -1 0 -1 -1 0 */
#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...