Submission #1078291

#TimeUsernameProblemLanguageResultExecution timeMemory
1078291mindiyakCarnival Tickets (IOI20_tickets)C++14
11 / 100
1 ms604 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++) { answer[i][0] = 0; temp.push_back(x[i][0]); } 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 += minus.top().F; used[minus.top().S] = 1; answer[minus.top().S][0] = 0; minus.pop(); } for(int i = 0;i<n/2;i++){ auto a = plus.top();plus.pop(); if(used[a.S]){ i--; continue; } ans += a.F; answer[a.S][m-1] = 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...