제출 #569886

#제출 시각아이디문제언어결과실행 시간메모리
569886ngpin04카니발 티켓 (IOI20_tickets)C++17
100 / 100
783 ms92796 KiB
#include "tickets.h" #include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define TASK "" #define bit(x) (1LL << (x)) #define getbit(x, i) (((x) >> (i)) & 1) #define ALL(x) (x).begin(), (x).end() using namespace std; template <typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { return l + rd() % (r - l + 1); } const int N = 1505; const int oo = 1e9; const long long ooo = 1e18; const int mod = 1e9 + 7; // 998244353; const long double pi = acos(-1); int sign[N][N]; int ans[N][N]; int cnt[N]; bool vis[N]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); long long tot = 0; memset(ans, -1, sizeof(ans)); vector <pair <int, int>> best; for (int i = 0; i < n; i++) { for (int j = m - k; j < m; j++) tot += x[i][j]; for (int l = 0, r = m - k; r < m; l++, r++) best.push_back({-x[i][l] - x[i][r], i}); } sort(ALL(best), greater <pair <int, int>> ()); int cntneg = 0; for (auto [val, i] : best) { tot += val; cnt[i]++; cntneg++; if (cntneg == (n >> 1) * k) break; } for (int i = 0, cur = 0; i < n; i++) { for (int j = 0; j < k; j++) vis[j] = false; for (int j = 0; j < cnt[i]; j++) { ans[i][j] = cur; vis[cur] = true; cur++; if (cur == k) cur = 0; } for (int j = m - (k - cnt[i]), res = 0; j < m; j++) { while (vis[res]) res++; ans[i][j] = res++; } } vector <vector <int>> answer; for (int i = 0; i < n; i++) { vector <int> row(m, 0); for (int j = 0; j < m; j++) row[j] = ans[i][j]; answer.push_back(row); } allocate_tickets(answer); return tot; } //#include "grader.cpp"
#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...