제출 #1062861

#제출 시각아이디문제언어결과실행 시간메모리
1062861jamjanek카니발 티켓 (IOI20_tickets)C++14
11 / 100
2 ms860 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; void usun(vector<int>&ile, set<pair<int, int>>&ilejedynek, int x){ pair<int,int> it = {ile[x], x}; ilejedynek.erase(it); ile[it.second]--; ilejedynek.insert({it.first-1, it.second}); } long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); int i, j; vector<vector<int>>answer(n); for(i=0;i<n;i++)answer[i].push_back(0); vector<int>zbior; for(auto j: x) zbior.push_back(j[0]); sort(zbior.begin(), zbior.end()); long long wynik = 0; for(i=0;i<n;i++) if(i<n/2) wynik-=zbior[i]; else wynik+=zbior[i]; allocate_tickets(answer); return wynik; /* set<pair<int,int>>ilejedynek; vector<int>ile; for(i=0;i<n;i++){ int suma = 0; for(j=0;j<m;j++) suma+=x[i][j]; ilejedynek.insert({suma, i}); ile.push_back(suma); } // for(i=0;i<n;i++)printf("%d ", ile[i]); vector<std::vector<int>> answer(n); int r = m; int wynik=0; for(int i=0;i<k;i++){ int pom = 0; for(j=0;j<n/2;j++) if((*ilejedynek.rbegin()).first>0){ auto it = *ilejedynek.rbegin(); answer[it.second].push_back(1); usun(ile, ilejedynek, it.second); pom++; } for(j=0;j<n;j++) if((int)answer[j].size()<=i){ if(ile[j]==r){ answer[j].push_back(1); usun(ile, ilejedynek, j); pom++; } else{ answer[j].push_back(0); } } wynik+=min(pom, n-pom); r--; } // for(i=0;i<n;i++)printf("%d ", ile[i]); for(i=0;i<n;i++){ while(ile[i]){ answer[i].push_back(1); ile[i]--; } while((int)answer[i].size()<m) answer[i].push_back(0); } // for(i=0;i<n;i++)printf("%d ", answer[i].size()); allocate_tickets(answer); return wynik;*/ }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:15:6: warning: unused variable 'm' [-Wunused-variable]
   15 |  int m = x[0].size();
      |      ^
tickets.cpp:16:9: warning: unused variable 'j' [-Wunused-variable]
   16 |  int i, j;
      |         ^
#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...