제출 #1078290

#제출 시각아이디문제언어결과실행 시간메모리
1078290mindiyak카니발 티켓 (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 += 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; } }

컴파일 시 표준 에러 (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...