제출 #625317

#제출 시각아이디문제언어결과실행 시간메모리
625317Trunkty카니발 티켓 (IOI20_tickets)C++14
14 / 100
685 ms101712 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; typedef long long ll; //#define ll ll; #include "tickets.h" ll pick[1505][1505]; vector<ll> zero[1505],one[1505]; ll find_maximum(int k, vector<vector<int>> x) { ll n = x.size(); ll m = x[0].size(); ll ret=0; vector<vector<ll>> v; for(ll i=0;i<n;i++){ for(ll j=0;j<m;j++){ if(x[i][j]==0){ zero[i].push_back(j); } else{ one[i].push_back(j); } } v.push_back({zero[i].size(),i}); } for(ll i=1;i<=k;i++){ sort(v.begin(),v.end()); ll cntz=0,cnto=0; for(ll j=0;j<n/2;j++){ ll p = v[j][1]; if(one[p].size()>0){ cnto++; pick[p][one[p].back()] = i; one[p].pop_back(); } else{ cntz++; pick[p][zero[p].back()] = i; zero[p].pop_back(); } } for(ll j=n/2;j<n;j++){ ll p = v[j][1]; if(zero[p].size()>0){ cntz++; pick[p][zero[p].back()] = i; zero[p].pop_back(); } else{ cnto++; pick[p][one[p].back()] = i; one[p].pop_back(); } } ret += min(cntz,cnto); v.clear(); for(ll j=0;j<n;j++){ v.push_back({zero[j].size(),j}); } } // vector<vector<int>> answer; for(ll i=0;i<n;i++) { vector<int> row(m); for(ll j=0;j<m;j++) { row[j] = pick[i][j]-1; } answer.push_back(row); } allocate_tickets(answer); return ret; }

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

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:28:28: warning: narrowing conversion of 'zero[i].std::vector<long long int>::size()' from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'long long int' [-Wnarrowing]
   28 |   v.push_back({zero[i].size(),i});
      |                ~~~~~~~~~~~~^~
tickets.cpp:28:28: warning: narrowing conversion of 'zero[i].std::vector<long long int>::size()' from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'long long int' [-Wnarrowing]
tickets.cpp:62:29: warning: narrowing conversion of 'zero[j].std::vector<long long int>::size()' from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'long long int' [-Wnarrowing]
   62 |    v.push_back({zero[j].size(),j});
      |                 ~~~~~~~~~~~~^~
tickets.cpp:62:29: warning: narrowing conversion of 'zero[j].std::vector<long long int>::size()' from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'long long int' [-Wnarrowing]
#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...