#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool cmp(pair<int, int> &a, pair<int, int> &b)
{
if(a.second != b.second)
{
return a.second>b.second;
}
else
{
if(a.first != b.first)
{
return a.first<b.first;
}
}
//return 0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, t, p;
cin>>n >>t >>p;
vector<int> points_for_each_task_array(t, 0);
vector<vector<int> > arr(n, {0, 0});
vector<pair<int, int>> final_standing(n, {0, 0});
//calculating points for each task
for(int i=0; i<n; i++)
{
for(int j=0; j<t; j++)
{
cin>>arr[i][j];
if(arr[i][j]==0)
{
points_for_each_task_array[j]++;
}
}
}
//calculating the no.of points that each contestant got
//And putting the contestant id and marks in the final_standing
for(int i=0; i<n; i++)
{
int ans=0;
for(int j=0; j<t; j++)
{
if(arr[i][j]==1)
{
ans+=points_for_each_task_array[j];
}
}
final_standing[i]={i, ans};
}
//sorting according to condition
sort(final_standing.begin(), final_standing.end(), cmp);
//printing (0 base indexing )
cout<<final_standing[p-1].second <<" " <<final_standing[p-1].first+1 <<"\n";
return 0;
}
Compilation message
poi.cpp: In function 'bool cmp(std::pair<int, int>&, std::pair<int, int>&)':
poi.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
18 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
4 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
5 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
6 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
7 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
8 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
9 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
10 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 6 |
11 |
Runtime error |
7 ms |
468 KB |
Execution killed with signal 6 |
12 |
Runtime error |
14 ms |
476 KB |
Execution killed with signal 6 |
13 |
Runtime error |
30 ms |
460 KB |
Execution killed with signal 6 |
14 |
Runtime error |
43 ms |
492 KB |
Execution killed with signal 6 |
15 |
Runtime error |
76 ms |
520 KB |
Execution killed with signal 6 |
16 |
Runtime error |
82 ms |
644 KB |
Execution killed with signal 6 |
17 |
Runtime error |
123 ms |
880 KB |
Execution killed with signal 6 |
18 |
Runtime error |
149 ms |
1532 KB |
Execution killed with signal 6 |
19 |
Runtime error |
183 ms |
3220 KB |
Execution killed with signal 6 |
20 |
Runtime error |
220 ms |
3928 KB |
Execution killed with signal 6 |