제출 #592684

#제출 시각아이디문제언어결과실행 시간메모리
592684ogibogi2004카니발 티켓 (IOI20_tickets)C++14
25 / 100
1045 ms175868 KiB
#include "tickets.h" #include <vector> #include<bits/stdc++.h> using namespace std; #define ll long long long long find_maximum(int k, vector<vector<int>> x1) { //cout<<"?\n"; vector<vector<ll> >x; for(int i=0;i<x1.size();i++) { vector<ll>row; for(int j=0;j<x1[i].size();j++)row.push_back(x1[i][j]); x.push_back(row); } ll n = x.size(); ll m = x[0].size(); vector<vector<int>> answer; vector<pair<ll,ll>>smallest[n]; int ptr1[n],ptr2[n]; for(ll i=0;i<n;i++) { for(ll j=0;j<m;j++)smallest[i].push_back({x[i][j],j}); sort(smallest[i].begin(),smallest[i].end()); ptr1[i]=0;ptr2[i]=smallest[i].size()-1; } answer=x1; for(int i=0;i<answer.size();i++) { for(int j=0;j<answer[i].size();j++) { answer[i][j]=-1; } } //cout<<min0<<" "<<max0<<" "<<n*k/2<<endl; ll target=0,ret=0; vector<int>zero[n],one[n]; vector<pair<ll,pair<int,int> > >xs; for(int i=0;i<n;++i) { for(int j=0;j<m;++j) { xs.push_back({(ll)x[i][j],{i,j}}); } } sort(xs.begin(),xs.end()); int med=xs.size()/2; int where[n][m]; for(int i=0;i<xs.size()/2;i++)target-=xs[i].first; for(int i=xs.size()/2;i<xs.size();i++)target+=xs[i].first; for(int i=0;i<xs.size();i++) { where[xs[i].second.first][xs[i].second.second]=i; } ret=target; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(where[i][j]<med)zero[i].push_back(j); else one[i].push_back(j); } } /*cout<<"eho2\n"; for(int i=0;i<n;i++) { cout<<zero[i].size()<<" "<<one[i].size()<<endl; }*/ //cout<<"?\n"; vector<pair<int,int> >v; for(int r=0;r<k;r++) { int f=n/2; //cout<<r<<" "<<k<<" "<<f<<endl; v.clear(); for(int i=0;i<n;i++) { v.push_back({zero[i].size(),i}); } sort(v.rbegin(),v.rend()); /*for(int j=0;j<v.size();j++)cout<<v[j].first<<" "; cout<<endl; cout<<target<<endl;*/ for(int j=0;j<v.size();j++) { if(j<f) { //if(zero[v[j].second].size()==0)cout<<"bruh0\n"; answer[v[j].second][zero[v[j].second].back()]=r; zero[v[j].second].pop_back(); } else { /*if(one[v[j].second].size()==0) { cout<<zero[v[j].second].size()<<" "<<one[v[j].second].size()<<endl; cout<<"bruh1\n"; cout<<j<<endl; }*/ answer[v[j].second][one[v[j].second].back()]=r; one[v[j].second].pop_back(); } } } allocate_tickets(answer); return ret; } /* 2 3 2 0 2 5 1 1 3 */ /* 4 4 3 0 1 1 1 0 1 1 1 0 1 1 1 0 0 0 1 */ /* 2 3 3 0 2 5 1 1 3 */

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<x1.size();i++)
      |                 ~^~~~~~~~~~
tickets.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for(int j=0;j<x1[i].size();j++)row.push_back(x1[i][j]);
      |                     ~^~~~~~~~~~~~~
tickets.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<answer.size();i++)
      |                 ~^~~~~~~~~~~~~~
tickets.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int j=0;j<answer[i].size();j++)
      |                     ~^~~~~~~~~~~~~~~~~
tickets.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int i=0;i<xs.size()/2;i++)target-=xs[i].first;
      |                 ~^~~~~~~~~~~~
tickets.cpp:50:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=xs.size()/2;i<xs.size();i++)target+=xs[i].first;
      |                           ~^~~~~~~~~~
tickets.cpp:51:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i=0;i<xs.size();i++)
      |                 ~^~~~~~~~~~
tickets.cpp:84:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |         for(int j=0;j<v.size();j++)
      |                     ~^~~~~~~~~
tickets.cpp:19:9: warning: variable 'ptr1' set but not used [-Wunused-but-set-variable]
   19 |     int ptr1[n],ptr2[n];
      |         ^~~~
tickets.cpp:19:17: warning: variable 'ptr2' set but not used [-Wunused-but-set-variable]
   19 |     int ptr1[n],ptr2[n];
      |                 ^~~~
#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...