제출 #483544

#제출 시각아이디문제언어결과실행 시간메모리
483544victorang1Poi (IOI09_poi)C++14
0 / 100
526 ms16452 KiB
// // main.cpp // sorting // // Created by Team SSG on 30/10/21. // #include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; struct Player { int score; int numberOfProblemSolved; }; bool mapComparator(pair<int, Player> &a, pair<int, Player> &b) { if (a.second.score > b.second.score) return true; else if (a.second.score < b.second.score) return false; if (a.second.numberOfProblemSolved > b.second.numberOfProblemSolved) return true; else if (a.second.numberOfProblemSolved < b.second.numberOfProblemSolved) return false; if (a.first < b.first) return true; return false; } vector<pair<int, Player>> sort(map<int, Player> &userScores) { vector<pair<int, Player>> temp; for (auto& it : userScores) { temp.push_back(it); } sort(temp.begin(), temp.end(), mapComparator); return temp; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int N, T, P; cin >> N >> T >> P; vector<vector<int>> tasks(N, vector<int>(T)); map<int, int> taskScores; for (int i = 0; i < N; ++i) { for (int j = 0; j < T; ++j) { cin >> tasks[i][j]; if (tasks[i][j] == 0) { taskScores[j] += 1; } } } map<int, Player> userScores; for (int i = 0; i < N; ++i) { for (int j = 0; j < T; ++j) { if (tasks[i][j] == 1) { userScores[i].score += taskScores[j]; userScores[i].numberOfProblemSolved++; } } } vector<pair<int, Player>> sortedPlayer = sort(userScores); for (auto& it : sortedPlayer) { cout << it.second.score << ' ' << it.first << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...