본문 바로가기
Programming/Judge

ACMICPC 1205 : 등수 구하기

by deviAk 2014. 12. 13.
반응형


http://www.acmicpc.net/problem/1205


<결과>




<코드>

#include<iostream>
#include<vector>
using namespace std;

int main()
{
	vector<int> scores;
	int num_score, score, max_rank;
	cin >> num_score >> score >> max_rank;

	for (int i = 0; i < num_score; i++)
	{
		int in_temp;
		cin >> in_temp;
		scores.push_back(in_temp);
	}

	if (num_score == max_rank && scores[num_score - 1] >= score) cout << "-1" << endl;
	else
	{
		int rank = 1;
		for (int i = 0; i < num_score; i++)
		{
			if (scores[i] > score) rank++;
			else break;
		}
		cout << rank << endl;
	}
	scores.clear();
	return 0;
}


반응형