Submission #580043

#TimeUsernameProblemLanguageResultExecution timeMemory
580043slime카니발 티켓 (IOI20_tickets)C++14
11 / 100
2 ms724 KiB
#include "bits/stdc++.h" #include "tickets.h" using namespace std; long long find_maximum(int k, std::vector<std::vector<int>> d); void allocate_tickets( std::vector<std::vector<int>> _x); long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row(m); for (int j = 0; j < m; j++) { row[j] = -1; } answer.push_back(row); } vector<pair<int, int> > v; for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { v.push_back({x[i][j], i}); } } sort(v.begin(), v.end()); int cnt[n]; for(int i=0; i<n; i++) cnt[i] = 0; int distinct = 0; long long s = 0; for(int i=0; i<v.size(); i++) { cnt[v[i].second]++; if(cnt[v[i].second] == 1) distinct++; if(distinct == n/2) { int b = v[i].first; int sad[n]; for(int j = v.size()-1; j >= 0; j--) { if(cnt[v[j].second] == 0) { cnt[v[j].second] = -1; s += v[j].first - b; sad[v[j].second] = v[j].first; } } for(int j=0; j<=i; j++) { if(cnt[v[j].second] > 0) { cnt[v[j].second] = -1; s += b - v[j].first; sad[v[j].second] = v[j].first; } } for(int j=0; j<n; j++) { for(int l=0; l<m; l++) { if(x[j][l] == sad[j]) { answer[j][l] = 0; break; } } } break; } } allocate_tickets(answer); return s; } //13210230

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:32:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int i=0; i<v.size(); i++) {
      |                ~^~~~~~~~~
#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...