# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629847 | chinmoy_101 | Poi (IOI09_poi) | C++14 | 220 ms | 3928 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
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |