제출 #607480

#제출 시각아이디문제언어결과실행 시간메모리
607480Jarif_Rahman카니발 티켓 (IOI20_tickets)C++17
14 / 100
459 ms57664 KiB
#include "tickets.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; ll find_maximum(int K, vector<vector<int>> v){ int n = v.size(), m = v[0].size(); vector<vector<int>> pos(n, vector<int>(m, -1)); ll ans = 0; vector<int> cnt(n), o(n); for(int i = 0; i < n; i++){ o[i] = i; cnt[i] = count(v[i].begin(), v[i].end(), 1); } vector<int> L(n, 0), R(n, m-1); for(int k = 0; k < K; k++){ sort(o.begin(), o.end(), [&cnt](int a, int b){ return cnt[a] < cnt[b]; }); for(int j = 0, i = o[0]; j < n/2; j++, i = o[j]){ pos[i][L[i]] = k; if(v[i][L[i]]) cnt[i]--; ans-=v[i][L[i]]; L[i]++; } for(int j = n/2, i = o[n/2]; j < n; j++, i = o[j]){ pos[i][R[i]] = k; if(v[i][R[i]]) cnt[i]--; ans+=v[i][R[i]]; R[i]--; } } allocate_tickets(pos); 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...