제출 #414990

#제출 시각아이디문제언어결과실행 시간메모리
414990keko37카니발 티켓 (IOI20_tickets)C++14
100 / 100
1022 ms144024 KiB
#include<bits/stdc++.h> #include "tickets.h" using namespace std; typedef long long llint; typedef pair <int, int> pi; const int MAXN = 1505; int n, m, k; int bio[MAXN][MAXN]; vector <pi> a[MAXN]; vector < pair <llint, pi> > v; llint find_maximum (int K, vector < vector <int> > A) { k = K; n = A.size(); m = A[0].size(); memset(bio, -1, sizeof bio); llint res = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i].push_back({A[i][j], j}); } sort(a[i].begin(), a[i].end()); for (int j = 0; j < k; j++) { bio[i][m - 1 - j] = 1; res += a[i][m - 1 - j].first; llint val = a[i][j].first + a[i][m - (k - j)].first; v.push_back({val, {i, j}}); } } sort(v.begin(), v.end()); for (int i = 0; i < n * k / 2; i++) { llint val = v[i].first; int row = v[i].second.first, col = v[i].second.second; res -= val; bio[row][m - (k - col)] = -1; bio[row][col] = 0; } vector < vector <int> > sol; vector <int> tmp(m, 0); for (int i = 0; i < n; i++) sol.push_back(tmp); int curr = 0; for (int i = 0; i < n; i++) { int nula = 0, jen = 0; for (int j = 0; j < m; j++) { if (bio[i][j] == 0) nula++; if (bio[i][j] == 1) jen++; if (bio[i][j] != -1) { sol[i][a[i][j].second] = curr % k; curr++; } else { sol[i][a[i][j].second] = -1; } } curr += nula; } allocate_tickets(sol); return res; }
#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...