Submission #359455

#TimeUsernameProblemLanguageResultExecution timeMemory
359455lakshith_Poi (IOI09_poi)C++14
100 / 100
673 ms16108 KiB
#include <bits/stdc++.h>

using namespace std;

struct student{
	int id;
	int tasks;
	int score;
};

bool comp(student s1,student s2){
	if(s1.score>s2.score)return true;
	else if(s1.score<s2.score)return false;
	else if(s1.tasks>s2.tasks)return true;
	else if(s1.tasks<s2.tasks)return false;
	else return (s1.id<s2.id);
}

int main(){
	int n,t,p;
	cin >> n >> t >> p;
	p--;
	vector<int> scores(t,n);
	vector<vector<int>> vec;
	for(int i=0;i<n;i++){
		vector<int> v;
		for(int j=0;j<t;j++){
			int a;
			cin >> a;
			if(a==1){
				scores[j]--;
				v.push_back(j);
			}
		}
		vec.push_back(v);
	}
	//for(int x:scores)cout <<  x << "\t";
	//cout << "\n";
	vector<student> students;
	for(int i=0;i<n;i++){
		int score = 0;
		for(int x:vec[i])score += scores[x];
		students.push_back({i,vec[i].size(),score});
		//cout << i << "\t" << vec[i].size() << "\t" << score << "\n";
	}
	sort(students.begin(),students.end(),comp);
	for(int i=0;i<n;i++)
		if(students[i].id==p){
			cout << students[i].score << " " << i+1 << "\n";
		}
}

Compilation message (stderr)

poi.cpp: In function 'int main()':
poi.cpp:43:36: warning: narrowing conversion of '(& vec.std::vector<std::vector<int> >::operator[](((std::vector<std::vector<int> >::size_type)i)))->std::vector<int>::size()' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   43 |   students.push_back({i,vec[i].size(),score});
      |                         ~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...