Submission #536060

#TimeUsernameProblemLanguageResultExecution timeMemory
536060Spartan117Poi (IOI09_poi)C++14
15 / 100
289 ms39664 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct contestant { int id; int score; int numOfTasksSolved; contestant() { id = 0; score = 0; numOfTasksSolved = 0; } }; bool compareContestants (contestant &contestant1, contestant &contestant2) { if (contestant1.score > contestant2.score) return true; else if (contestant1.score == contestant2.score) { if (contestant1.numOfTasksSolved > contestant2.numOfTasksSolved) return true; else if (contestant1.numOfTasksSolved == contestant2.numOfTasksSolved) return contestant1.id < contestant2.id; else return false; } else return false; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n{}, t{}, p{}; cin >> n >> t >> p; vector<vector<int>> contestant_solvedTask (n); //reading input for (int i{}; i<n; i++) { for (int j{}; j<t; j++) { int taskSolved{}; cin >> taskSolved; contestant_solvedTask[i].push_back(taskSolved); } } vector<int> taskScores (t); for (int i{}; i<n; i++) //calculating points for each task { for (int j{}; j<n; j++) { if (contestant_solvedTask[i][j]==0) taskScores[j]++; } } vector<contestant> contestants (n) ; //finding scores and numOfTasksSolved by each student for (int i{}; i<n; i++) { contestants[i].id = i; for (int j{}; j<n; j++) { if (contestant_solvedTask[i][j]==1) { contestants[i].score += taskScores[j]; contestants[i].numOfTasksSolved++; } } } sort(contestants.begin(), contestants.end(), compareContestants); //ranking them (sorting) int philipScore {}, philipRank {}; for (int i{}; i<n; i++) //finding philip's score and rank { if (contestants[i].id==p-1) { philipScore = contestants[i].score; philipRank = i+1; break; } } cout << philipScore << ' ' <<philipRank << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...