제출 #541950

#제출 시각아이디문제언어결과실행 시간메모리
541950DemonLord154Poi (IOI09_poi)C++14
컴파일 에러
0 ms0 KiB
#include<iostream> #include<vector> using namespace std; struct Player{ int score; int id; int probSolved; }; bool comparator(Player player1,Player player2){ if (player1.score != player2.score){ return player1.score<player2.score; } if (player1.probSolved!= player2.probSolved){ return player1.probSolved < player2.probSolved; } return player1.id<player2.id; } int main(){ int n,t,p; cin>>n>>t>>p; vector<Player> players(n); int scores[n][t]; for (int i=0;i<n;i++){ for (int j=0;j<t;j++){ cin>>scores[i][j]; } } vector<int> eachTestScore(t); for (int i=0;i<t;i++){ int score=0; for (int j=0;j<n;j++){ if (scores[j][i]==0){ score++; } } eachTestScore[i]=score; } for (int i=0;i<n;i++){ int playerScore=0,probsolved=0; for (int j=0;j<t;j++){ if (scores[i][j]==1){ playerScore+=eachTestScore[j]; probsolved++; } } players[i].score=playerScore; players[i].id=i; players[i].probSolved=probsolved; } sort(players.begin(),players.end(),comparator); for (int i=0;i<n;i++){ if (players[i].id==p-1){ cout<<players[i].score<<" "<<n-i<<endl; break; } } }

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

poi.cpp: In function 'int main()':
poi.cpp:50:3: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   50 |   sort(players.begin(),players.end(),comparator);
      |   ^~~~
      |   qsort