제출 #822399

#제출 시각아이디문제언어결과실행 시간메모리
822399Username4132카니발 티켓 (IOI20_tickets)C++14
27 / 100
617 ms178808 KiB
#include "tickets.h" #include<iostream> #include <vector> #include<algorithm> #include<set> using namespace std; using ll = long long; using pii = pair<int, int>; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define forsn(i, s, n) for(int i=s; i<(int)n; ++i) #define PB push_back #define F first #define S second const int MAXN = 1510; int n, m; set<pii> wii[MAXN]; long long find_maximum(int k, std::vector<std::vector<int>> x) { n = (int)x.size(); m = (int)x[0].size(); ll ret=0; vector<vector<int>> ans(n, vector<int>(m, -1)); forn(i, n){ vector<pii> tem(m); forn(j, m) tem[j] = {x[i][j], j}; set<pii> tmp(tem.begin(), tem.end()); swap(wii[i], tmp); } forn(tur, k){ ll sum = 0; vector<pii> obt(n); forn(i, n) sum-=wii[i].begin()->F; forn(i, n) obt[i] = {wii[i].begin()->F + wii[i].rbegin()->F, i}; sort(obt.begin(), obt.end(), greater<pii>()); forn(i, (n>>1)){ sum+=obt[i].F; ans[obt[i].S][wii[obt[i].S].rbegin()->S] = tur; wii[obt[i].S].erase(prev(wii[obt[i].S].end())); } forsn(i, (n>>1), n){ ans[obt[i].S][wii[obt[i].S].begin()->S] = tur; wii[obt[i].S].erase(wii[obt[i].S].begin()); } ret+=sum; } allocate_tickets(ans); return ret; }
#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...