# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
663298 | esomer | Poi (IOI09_poi) | C++17 | 228 ms | 16048 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int MOD = 1e9 + 7;
void solve(){
int n, t, p; cin >> n >> t >> p; p--;
vector<int> scores(t, n);
vector<vector<int>> v(n, vector<int>(t));
for(int i = 0; i < n; i++){
for(int j = 0; j < t; j++){
int x; cin >> x;
if(x == 1) scores[j]--;
v[i][j] = x;
}
}
vector<tuple<int, int, int>> res(n);
for(int i = 0; i < n; i++){
int score = 0;
int tasks = 0;
for(int j = 0; j < t; j++){
if(v[i][j]) {score += scores[j]; tasks++;}
}
res[i] = {score, tasks, i};
}
function<bool(tuple<int, int, int>, tuple<int, int, int>)> cmp = [&](tuple<int, int, int> a, tuple<int, int, int> b){
if(get<0>(a) == get<0>(b)){
if(get<1>(a) == get<1>(b)) return get<2>(a) < get<2>(b);
else return get<1>(a) > get<1>(b);
}else return get<0>(a) > get<0>(b);
};
sort(res.begin(), res.end(), cmp);
for(int i = 0; i < n; i++){
if(get<2>(res[i]) == p){
cout << get<0>(res[i]) << " "<< i + 1 << endl;
return;
}
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("inpt.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
//int tt; cin >> tt;
int tt = 1;
for(int t = 1; t <= tt; t++){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |