제출 #830007

#제출 시각아이디문제언어결과실행 시간메모리
830007Baytoro카니발 티켓 (IOI20_tickets)C++17
27 / 100
433 ms51392 KiB
#include "tickets.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second //#define int long long long long find_maximum(int k, vector<vector<int>> x) { int n=x.size(),m=x[0].size(); if(k==1){ vector<vector<int>> ans(n,vector<int>(m,-1)); vector<pair<int,int>> v(n); vector<int> a; for(int i=0;i<n;i++){ v[i]={x[i][0]+x[i][m-1],i}; } sort(v.begin(),v.end()); for(int i=0;i<n/2;i++){ ans[v[i].sc][0]=0; a.pb(x[v[i].sc][0]); } for(int i=n/2;i<n;i++){ ans[v[i].sc][m-1]=0; a.pb(x[v[i].sc][m-1]); } allocate_tickets(ans); sort(a.begin(),a.end()); long long s=(a[n/2]),res=0; for(int i=0;i<n;i++) res+=abs(s-a[i]); return res; } else if(k==m){ vector<vector<int>> ans(n,vector<int>(m,-1)); int res=0; for(int t=0;t<k;t++){ vector<pair<pair<int,int>,pair<int,int>>> v(n); for(int i=0;i<n;i++){ bool ok=0; for(int j=0;j<m;j++){ if(ans[i][j]!=-1) continue; if(!ok) v[i].sc.fr=j; v[i].sc.sc=j; ok=1; } v[i].fr.sc=i; v[i].fr.fr=(x[i][v[i].sc.fr]+x[i][v[i].sc.sc]); } sort(v.begin(),v.end());vector<int> a; for(int i=0;i<n/2;i++){ a.pb(x[v[i].fr.sc][v[i].sc.fr]); ans[v[i].fr.sc][v[i].sc.fr]=t; } for(int i=n/2;i<n;i++){ a.pb(x[v[i].fr.sc][v[i].sc.sc]); ans[v[i].fr.sc][v[i].sc.sc]=t; } sort(a.begin(),a.end()); int s=a[n/2]; for(int i=0;i<n;i++) res+=abs(s-a[i]); } allocate_tickets(ans); return res; } }

컴파일 시 표준 에러 (stderr) 메시지

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
   66 | }
      | ^
#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...