제출 #428634

#제출 시각아이디문제언어결과실행 시간메모리
428634alireza_kaviani카니발 티켓 (IOI20_tickets)C++17
16 / 100
803 ms65216 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define sep ' ' const int MAXN = 1510; int ptr[MAXN] , sum[MAXN] , L[MAXN] , R[MAXN] , F[MAXN][MAXN]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size() , m = x[0].size(); ll ans = 0 , S = 0; vector<pii> vec; vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row(m , 0); for (int j = 0; j < k; j++) { ans += x[i][m - k + j]; F[i][m - k + j] = 1; vec.push_back({x[i][j] + x[i][m - k + j] , i}); } answer.push_back(row); } sort(vec.begin(), vec.end()); for(int i = 0 ; i < n * k / 2 ; i++){ int val = vec[i].first , id = vec[i].second; ans -= val; //cout << val << sep << id << endl; F[id][ptr[id]] = -1; F[id][m - k + ptr[id]] = 0; ptr[id]++; } for(int i = 0 ; i < n ; i++){ L[i] = 0; R[i] = m - 1; for(int j = 0 ; j < m ; j++){ sum[i] += F[i][j]; answer[i][j] = -1; S += F[i][j] * x[i][j]; } } assert(S == ans); for(int i = 0 ; i < k ; i++){ vector<pii> v; for(int j = 0 ; j < n ; j++){ v.push_back({sum[j] , j}); } sort(v.begin(), v.end()); for(int j = 0 ; j < n ; j++){ int id = v[j].second; if(j < n / 2){ sum[id]++; answer[id][L[id]++] = i; } else{ sum[id]--; answer[id][R[id]--] = i; } } } allocate_tickets(answer); return S; }
#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...