제출 #580472

#제출 시각아이디문제언어결과실행 시간메모리
580472joelau카니발 티켓 (IOI20_tickets)C++14
25 / 100
897 ms146668 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long A[1505][1505], B[1505], C[1505]; vector< tuple<long long,long long,long long> > lst; bitset<1505> bs; 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) for (long long j = 0; j < M; ++j) lst.emplace_back(x[i][j],i,j); sort(lst.begin(),lst.end()); memset(A,0,sizeof(A)); for (long long i = 0; i < N*M/2; ++i) A[get<1>(lst[i])][get<2>(lst[i])] = 1; memset(B,0,sizeof(B)); memset(C,0,sizeof(C)); for (long long i = 0; i < N; ++i) { while (C[i] < M && A[i][C[i]] == 1) C[i]++; } long long val = 0; vector< vector<int> > ans (N, vector<int>(M,-1)); for (long long j = 0; j < M; ++j) { bs.reset(); long long cnt = 0; for (long long i = 0; i < N; ++i) { if (B[i] == M || A[i][B[i]] == 0) ans[i][C[i]] = j, val += x[i][C[i]], C[i]++, bs[i] = 1; else if (C[i] == M) ans[i][B[i]] = j, cnt++, val -= x[i][B[i]], B[i]++, bs[i] = 1; } for (long long i = 0; i < N; ++i) if (!bs[i]) { if (cnt < N/2 && A[i][B[i]] == 1) ans[i][B[i]] = j, cnt++, val -= x[i][B[i]], B[i]++; else ans[i][C[i]] = j, val += x[i][C[i]], C[i]++; } } 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...