Submission #1078286

#TimeUsernameProblemLanguageResultExecution timeMemory
1078286mindiyakCarnival Tickets (IOI20_tickets)C++14
0 / 100
1 ms760 KiB
#include "tickets.h" #include <vector> #include <algorithm> #include <set> #include <queue> using namespace std; #define F first #define S second typedef long long ll; ll 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(n,vector<int>(m,-1)); if(m == 1){ ll val = 0; vector<int> temp; for (int i = 0; i < n; i++) { std::vector<int> row(m,-1); row[0] = 0; temp.push_back(x[i][0]); answer.push_back(row); } sort(temp.begin(),temp.end()); for (int i = 0; i < n/2; i++)val -= temp[i]; for (int i = n/2; i < n; i++)val += temp[i]; allocate_tickets(answer); return val; } if(k == 1){ priority_queue<pair<int,int>> plus,minus; for (int i = 0; i < n; i++)plus.push({x[i][m-1],i}); for (int i = 0; i < n; i++)minus.push({-x[i][0],i}); vector<int> used(n,0); ll ans = 0; for(int i = 0;i<n/2;i++){ ans += plus.top().F; used[plus.top().S] = 1; answer[plus.top().S][m-1] = 0; plus.pop(); } for(int i = 0;i<n/2;i++){ auto a = minus.top();minus.pop(); if(used[a.S]){ i--; continue; } ans += a.F; answer[a.S][0] = 0; } allocate_tickets(answer); return ans; } }

Compilation message (stderr)

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:14:58: warning: control reaches end of non-void function [-Wreturn-type]
   14 |  std::vector<std::vector<int>> answer(n,vector<int>(m,-1));
      |                                                          ^
#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...