제출 #397736

#제출 시각아이디문제언어결과실행 시간메모리
397736leinad2카니발 티켓 (IOI20_tickets)C++17
25 / 100
1237 ms113876 KiB
#include"tickets.h" #include<bits/stdc++.h> using namespace std; long long find_maximum(int k, vector<vector<int> > x) { int n=x.size();int m=x[0].size();int i, j; vector<pair<int, pair<int, int> > >v; vector<vector<int> >chk; chk.resize(n); for(i=0;i<n;i++)chk[i].resize(m); vector<int>zero[1510], one[1510]; for(i=0;i<n;i++) { for(j=0;j<m;j++) { v.push_back({x[i][j], {i, j}}); } } sort(v.begin(), v.end()); long long ans=0; for(i=0;i<v.size();i++) { if(2*i<v.size())ans-=v[i].first; else ans+=v[i].first,chk[v[i].second.first][v[i].second.second]=1; } for(i=0;i<n;i++) { for(j=0;j<m;j++) { (chk[i][j]==0?zero:one)[i].push_back(j); } } vector<vector<int> >res; res.resize(n); for(i=0;i<n;i++) { res[i].resize(m); for(j=0;j<m;j++)res[i][j]=-1; } for(j=0;j<m;j++) { vector<pair<int, int> >v; for(i=0;i<n;i++)v.push_back({one[i].size(), i}); sort(v.begin(), v.end()); for(i=0;i<v.size();i++) { if(2*i<v.size()) { int a=v[i].second; int b=zero[a].back(); zero[a].pop_back(); res[a][b]=j; } else { int a=v[i].second; int b=one[a].back(); one[a].pop_back(); res[a][b]=j; } } } allocate_tickets(res); return ans; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:21:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(i=0;i<v.size();i++)
      |             ~^~~~~~~~~
tickets.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         if(2*i<v.size())ans-=v[i].first;
      |            ~~~^~~~~~~~~
tickets.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
tickets.cpp:47:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             if(2*i<v.size())
      |                ~~~^~~~~~~~~
#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...