제출 #1011233

#제출 시각아이디문제언어결과실행 시간메모리
1011233Cookie카니발 티켓 (IOI20_tickets)C++14
100 / 100
596 ms114604 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; #define sz(a) (int)a.size() #define ALL(v) v.begin(), v.end() #define ALLR(v) v.rbegin(), v.rend() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> #define mpp make_pair const ld PI = 3.14159265359, prec = 1e-9;; //using u128 = __uint128_t; const int cox[4] = {1, 0, -1, 0}; #include <vector> const int coy[4] = {0, -1, 0, 1}; const ll mod = 1e9 + 7, pr = 31; const int mxn = 1505, mxd = 250 * 250, sq = 100, mxv = 5e4 + 1; //const int base = (1 <<18); const ll inf = 1e9 + 5, neg = -69420, inf2 = 1e14; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); // have fun! #include "tickets.h" /* #include <cassert> #include <cstdio> #include <vector> #include <string> static int n; static int m; static int k; static std::vector<std::vector<int>> d; static std::vector<std::vector<int>> x; static int called = 0; static void check(bool cond, std::string message) { if (!cond) { printf("%s\n", message.c_str()); exit(0); } } void allocate_tickets( std::vector<std::vector<int>> _d) { check(!called, "allocate_tickets called more than once"); d = _d; check((int)d.size() == n, "allocate_tickets called with parameter of wrong size"); for (int i = 0; i < n; i++) { check((int)d[i].size() == m, "allocate_tickets called with parameter of wrong size"); } called = 1; } */ int mn[mxn + 1], mx[mxn + 1]; bool seen[mxn + 1]; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = sz(x), m = sz(x[0]); vt<vt<int>>res(n, vt<int>(m, -1)); for(int i = 0; i < n; i++){ mn[i] = -1; mx[i] = m; } ll ans = 0; vt<pll>comp; for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ ans -= x[i][j]; comp.pb(mpp(x[i][j] + x[i][m - (k - j)], i)); } mn[i] = k - 1; } //cout << ans << ' '; sort(ALLR(comp)); for(int i = 0; i < n / 2 * k; i++){ ans += comp[i].fi; mx[comp[i].se]--; mn[comp[i].se]--; } for(int i = 0; i < k; i++){ vt<pii>cand; for(int j = 0; j < n; j++){ cand.pb(mpp(mn[j], j)); } sort(ALLR(cand)); for(int j = 0; j < n / 2; j++){ res[cand[j].se][cand[j].fi] = i; seen[cand[j].se] = 1; mn[cand[j].se]--; } for(int j = 0; j < n; j++){ if(!seen[j]){ res[j][mx[j]++] = i; } } for(int j = 0; j < n; j++)seen[j] = 0; } allocate_tickets(res); return ans; } /* int main() { assert(scanf("%d %d %d", &n, &m, &k) == 3); x.resize(n); for (int i = 0; i < n; i++) { x[i].resize(m); for (int j=0; j < m; j++) { assert(scanf("%d", &x[i][j]) == 1); } } fclose(stdin); long long answer = find_maximum(k, x); check(called, "failure to call allocate_tickets"); printf("%lld\n", answer); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (j) printf(" "); printf("%d", d[i][j]); } printf("\n"); } fclose(stdout); return 0; } */
#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...