제출 #1039752

#제출 시각아이디문제언어결과실행 시간메모리
1039752Dan4Life카니발 티켓 (IOI20_tickets)C++17
100 / 100
618 ms92584 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define sz(a) (int)a.size() using vi = vector<int>; using ll = long long; using ar2 = array<ll,2>; ll find_maximum(int k, vector<vi> A) { int n = sz(A), m = sz(A[0]); ll tot = 0; vector<vi> a(n,vi(m,-1)); vi row(n,0); priority_queue<ar2> pq = priority_queue<ar2>(); for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) tot+=A[i][m-k+j], pq.push({-A[i][j]-A[i][m-k+j],i}); int num = n*k/2; while(num--){ auto [cost,i] = pq.top(); row[i]++, tot+=cost; pq.pop(); } int L = 0, R = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < row[i]; j++) a[i][j]=L++, L%=k; R=L; for(int j = m-k+row[i]; j < m; j++) a[i][j]=R++, R%=k; } allocate_tickets(a); return tot; }
#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...