제출 #608414

#제출 시각아이디문제언어결과실행 시간메모리
608414Mher카니발 티켓 (IOI20_tickets)C++14
62 / 100
3036 ms203936 KiB
#include <bits/stdc++.h> #include "tickets.h" #include <vector> using namespace std; int n; int m; long long res = 0; vector<int> l, r; vector<vector<int>> sg, ans; set<pair<int, pair<int, int>>> prio; long long find_maximum(int k, vector<vector<int>> x) { n = x.size(); m = x[0].size(); l.resize(n, 0); r.resize(n, m - 1); sg.resize(n, vector<int>(m, 0)); ans.resize(n, vector<int>(m, -1)); for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { sg[i][j] = -1; int s, p; s = x[i][j]; p = x[i][m - k + j]; prio.insert(make_pair(-s - p, make_pair(i, j))); res -= s; } } int cnt = 0; for (auto it = prio.begin(); cnt < n * k / 2; cnt++, it++) { auto v = *it; res -= v.first; auto pos = v.second; sg[pos.first][pos.second] = 0; sg[pos.first][m - k + pos.second] = 1; } for (int t = 0; t < k; t++) { int plus = 0; for (int i = 0; i < n; i++) { if (sg[i][l[i]] != -1) { plus++; } } for (int i = 0; i < n; i++) { if (sg[i][l[i]] != -1) { ans[i][r[i]] = t; //res += x[i][r[i]]; r[i]--; } else if (sg[i][r[i]] != 1) { ans[i][l[i]] = t; //res -= x[i][l[i]]; l[i]++; } else { if (plus < n / 2) { plus++; ans[i][r[i]] = t; //res += x[i][r[i]]; r[i]--; } else { ans[i][l[i]] = t; //res -= x[i][l[i]]; l[i]++; } } } } allocate_tickets(ans); 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...