제출 #580476

#제출 시각아이디문제언어결과실행 시간메모리
580476joelau카니발 티켓 (IOI20_tickets)C++14
0 / 100
1 ms212 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long A[1005], B[1005]; vector<long long> tmp; vector< pair<long long,long long> > lst; long long find_maximum(int k, vector<vector<int>> x) { long long N = x.size(), M = x[0].size(); for (long long i = 0; i < N; ++i) { long long sum = 0; for (long long j = 0; j < M; ++j) sum += x[i][j], tmp.push_back(x[i][j]); lst.emplace_back(sum,i); } sort(lst.begin(),lst.end()); sort(tmp.begin(),tmp.end()); long long zero = 0, one = 0, val = 0; for (long long i = 0; i < N*k/2; ++i) { if (tmp[i] == 0) zero++; else one++, val--; if (tmp[N*M-i-1] == 0) zero++; else one++, val++; } memset(A,0,sizeof(A)); memset(B,0,sizeof(B)); for (long long i = 0; i < N; ++i) while (B[i] < M && x[i][B[i]] == 0) B[i]++; vector< vector<int> > ans (N, vector<int>(M,-1)); for (long long i = 0; i < N; ++i) { long long n = lst[i].second; for (long long j = 0; j < k; ++j) { if (zero != 0 && A[n] < M && x[n][A[n]] == 0) zero--, ans[n][A[n]] = j, A[n]++; else one--, ans[n][B[n]] = j, B[n]++; } } allocate_tickets(ans); return val; }
#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...