제출 #527647

#제출 시각아이디문제언어결과실행 시간메모리
527647Deepesson카니발 티켓 (IOI20_tickets)C++17
100 / 100
765 ms93252 KiB
#include <bits/stdc++.h> #include "tickets.h" void allocate_tickets( std::vector<std::vector<int>> _d); typedef std::pair<int,int> pii; long long find_maximum(int k, std::vector<std::vector<int>> x) { int N=x.size(),M=x[0].size(); int lado=(k*N)/2; int pegou[N]={}; std::priority_queue<pii> queue; std::vector<std::deque<int>> copia; for(int i=0;i!=N;++i){ std::deque<int> k; for(auto&z:x[i])k.push_back(z); copia.push_back(k); } long long res=0; std::deque<int> remove[N]; for(int i=0;i!=N;++i){ for(int j=0;j!=k;++j){ remove[i].push_back(x[i][j]); res-=x[i][j]; } } for(int i=0;i!=N;++i){ if(remove[i].size()){ queue.push({remove[i].back()+copia[i].back(),i}); } } std::vector<int> pega[N]={}; for(int i=0;i!=lado;++i){ auto __ = queue.top(); queue.pop(); res+=__.first; copia[__.second].pop_back(); pega[__.second].push_back(copia[__.second].size()); remove[__.second].pop_back(); if(remove[__.second].size()){ queue.push({remove[__.second].back()+copia[__.second].back(),__.second}); } } std::vector<std::vector<int>> ordem; for(int i=0;i!=N;++i){ std::vector<int> p; for(int j=0;j!=M;++j)p.push_back(-1); ordem.push_back(p); } int adds[k]={},subs[k]={}; for(int i=0;i!=N;++i){ int rem = remove[i].size(); int cur=0; std::vector<int> falta; std::vector<pii> tem; for(int i=0;i!=k;++i){ tem.push_back({subs[i],i}); } std::sort(tem.begin(),tem.end()); bool foi[k]={}; ///Remove for(int j=0;j!=rem;++j){ if(subs[tem[cur].second]<(N/2)){ //std::cout<<"Adder "<<cur<<"\n"; foi[tem[cur].second]=1; subs[tem[cur].second]++; ordem[i][j]=tem[cur].second; }else {falta.push_back(tem[cur].second);--j;} ++cur; } while(cur<k){falta.push_back(tem[cur].second);++cur;} cur=0; ///Adiciona for(int j=copia[i].size();j!=x[i].size();++j){ //std::cout<<"Add "<<falta[cur]<<"\n"; ordem[i][j]=falta[cur]; ++cur; } // std::cout<<"\n"; } allocate_tickets(ordem); return res; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:72:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         for(int j=copia[i].size();j!=x[i].size();++j){
      |                                   ~^~~~~~~~~~~~~
tickets.cpp:9:6: warning: unused variable 'pegou' [-Wunused-variable]
    9 |  int pegou[N]={};
      |      ^~~~~
tickets.cpp:48:9: warning: unused variable 'adds' [-Wunused-variable]
   48 |     int adds[k]={},subs[k]={};
      |         ^~~~
#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...