Submission #1080420

#TimeUsernameProblemLanguageResultExecution timeMemory
1080420vjudge1Poi (IOI09_poi)C++17
100 / 100
399 ms24020 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct part { int id; int sc; int sv; }; bool comp(const part&a, const part&b) { if (a.sc != b.sc) return a.sc > b.sc; if (a.sv != b.sv) return a.sv > b.sv; return a.id < b.id; } int main() { int n, t, p; cin >> n >> t >> p; vector<vector<int>> v(n, vector<int>(t)); vector<int> sum(t, 0); vector<part> pr(n); for (int i = 0; i < n; i++) { for (int j = 0; j < t; j++) { cin >> v[i][j]; } } for (int j = 0; j < t; j++) { for (int i = 0; i < n; i++) { if (v[i][j] == 0) sum[j]++; } } for (int i = 0; i < n; i++) { pr[i].id = i + 1; pr[i].sc = 0; pr[i].sv = 0; for (int j = 0; j < t; j++) { if (v[i][j] == 1) { pr[i].sc += sum[j]; pr[i].sv++; } } } sort(pr.begin(), pr.end(), comp); int fsc = 0, rank = 1; for (int i = 0; i < n; i++) { if (pr[i].id == p) { fsc = pr[i].sc; rank = i + 1; break; } } cout << fsc << ' ' << rank; }
#Verdict Execution timeMemoryGrader output
Fetching results...