Submission #309312

#TimeUsernameProblemLanguageResultExecution timeMemory
309312tjdgus4384Carnival Tickets (IOI20_tickets)C++14
100 / 100
1250 ms54604 KiB
#include<bits/stdc++.h> #include "tickets.h" using namespace std; int cnt1[1501], cnt2[1501]; long long find_maximum(int k, vector<vector<int> > x){ vector<vector<int> > s(x.size()); for(int i = 0;i < s.size();i++) s[i].resize(x[0].size(), -1); vector<pair<int, int> > v; long long ret = 0; priority_queue<pair<pair<long long, int>, pair<int, int> > > pq; for(int i = 0;i < x.size();i++){ for(int j = 0;j < k;j++){ ret -= x[i][j]; cnt1[i]++; } pq.push({{x[i].back() + x[i][k - 1], i}, {x[i].size() - 1, k - 1}}); } for(int i = 0;i < k*x.size()/2;i++){ ret += pq.top().first.first; int a = pq.top().second.first; int b = pq.top().second.second; int c = pq.top().first.second; cnt1[c]--; cnt2[c]++; pq.pop(); if(a == 0 || b == 0) continue; pq.push({{x[c][a-1] + x[c][b-1], c}, {a-1, b-1}}); } for(int i = 0;i < x.size();i++) v.push_back({cnt1[i], cnt2[i]}); priority_queue<pair<pair<int, int>, int> > q; for(int i = 0;i < k;i++){ for(int j = 0;j < x.size();j++) q.push({{v[j].first, v[j].second}, j}); for(int j = 0;j < x.size()/2;j++){ s[q.top().second][q.top().first.first-1] = i; v[q.top().second].first--; q.pop(); } for(int j = 0;j < x.size()/2;j++){ s[q.top().second][x[0].size()-q.top().first.second] = i; v[q.top().second].second--; q.pop(); } } allocate_tickets(s); return ret; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:8:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i = 0;i < s.size();i++) s[i].resize(x[0].size(), -1);
      |                   ~~^~~~~~~~~~
tickets.cpp:13:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i = 0;i < x.size();i++){
      |                   ~~^~~~~~~~~~
tickets.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0;i < k*x.size()/2;i++){
      |                   ~~^~~~~~~~~~~~~~
tickets.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0;i < x.size();i++) v.push_back({cnt1[i], cnt2[i]});
      |                   ~~^~~~~~~~~~
tickets.cpp:35:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int j = 0;j < x.size();j++) q.push({{v[j].first, v[j].second}, j});
      |                       ~~^~~~~~~~~~
tickets.cpp:36:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int j = 0;j < x.size()/2;j++){
      |                       ~~^~~~~~~~~~~~
tickets.cpp:41:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int j = 0;j < x.size()/2;j++){
      |                       ~~^~~~~~~~~~~~
#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...