# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
501506 |
2022-01-03T14:30:51 Z |
aryan12 |
Poi (IOI09_poi) |
C++17 |
|
254 ms |
39620 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
bool cmp(array<int, 3> a, array<int, 3> b) {
if(a[0] == b[0]) {
if(a[1] == b[1]) {
return a[2] < b[2];
}
return a[1] > b[1];
}
return a[0] > b[0];
}
void Solve() {
int n, t, p;
cin >> n >> t >> p;
int a[n + 1][t + 1];
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= t; j++) {
cin >> a[i][j];
}
}
int points[t + 1];
for(int j = 1; j <= t; j++) {
int cnt = 0;
for(int i = 1; i <= n; i++) {
cnt += 1 - a[i][j];
}
points[j] = cnt;
}
vector<array<int, 3> > ranking;
for(int i = 1; i <= n; i++) {
int cnt_of_points = 0, cnt_of_solves = 0;
for(int j = 1; j <= t; j++) {
if(a[i][j] == 1) {
cnt_of_solves++;
cnt_of_points += points[j];
}
}
ranking.push_back({cnt_of_points, cnt_of_solves, i});
}
sort(ranking.begin(), ranking.end(), cmp);
for(int i = 0; i < ranking.size(); i++) {
if(ranking[i][2] == p) {
cout << ranking[i][0] << " " << i + 1 << "\n";
return;
}
}
assert(false);
}
int32_t main() {
auto begin = std::chrono::high_resolution_clock::now();
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) {
Solve();
}
auto end = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
return 0;
}
Compilation message
poi.cpp: In function 'void Solve()':
poi.cpp:46:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i = 0; i < ranking.size(); i++) {
| ~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
460 KB |
Output is correct |
10 |
Correct |
2 ms |
588 KB |
Output is correct |
11 |
Correct |
7 ms |
1492 KB |
Output is correct |
12 |
Correct |
12 ms |
2252 KB |
Output is correct |
13 |
Correct |
34 ms |
6112 KB |
Output is correct |
14 |
Correct |
56 ms |
8632 KB |
Output is correct |
15 |
Correct |
88 ms |
15044 KB |
Output is correct |
16 |
Correct |
99 ms |
16228 KB |
Output is correct |
17 |
Correct |
144 ms |
23872 KB |
Output is correct |
18 |
Correct |
169 ms |
26976 KB |
Output is correct |
19 |
Correct |
224 ms |
35540 KB |
Output is correct |
20 |
Correct |
254 ms |
39620 KB |
Output is correct |