# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
838367 | 2023-08-26T17:32:07 Z | ma_moutahid | Carnival Tickets (IOI20_tickets) | C++17 | 3000 ms | 212 KB |
#include "tickets.h" #include <vector> #include<bits/stdc++.h> using namespace std; long long prize=0; using ll=long long; #define vi vector<long long> #define vii vector<vi> #define pi pair<long long,long long> ll INF=1e9; vector<vi> ans; int n,m; long long find_maximum(int k, std::vector<std::vector<int>> x) { n = x.size(); m = x[0].size(); long long prize=0; std::vector<std::vector<int>> answer(n, std::vector<int>(m)); vector<vi>ones(n); vector<vi>zeroes(n); map<int,int>diff; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(x[i][j])ones[i].push_back(j); else { zeroes[i].push_back(j);} } diff.insert(pi(ones[i].size()-zeroes[i].size(),i)); } ll result=0; for(int i=0;i<k;i++){ vi used(n); int z=0;int o=0; auto b=diff.rbegin(); int ao=0; int az=0; while(o<n/2){ int node=b->second; if(used[node])continue; used[node]=1; o++; if(!ones[node].empty()){ answer[node][ones[node].back()]=i; ones[node].pop_back(); ao++; } else { answer[node][zeroes[node].back()]=i; zeroes[node].pop_back(); } } auto b2=diff.begin(); while(z<n/2){ int node=b2->second; if(used[node])continue; used[node]=1; z++; if(!zeroes[node].empty()){ answer[node][zeroes[node].back()]=i; zeroes[node].pop_back(); az++; } else { answer[node][ones[node].back()]=i; ones[node].pop_back(); } } result+=min(ao,az); } allocate_tickets(answer); return result; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3052 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3075 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3043 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3059 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3063 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3063 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3052 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |