Accept today?HDU1177,水題記錄:)

After yesterday發表於2020-09-24

Accept today?HDU1177,水題記錄:)

using namespace std;
#include<iostream>
#include<algorithm>
#include<string.h>
struct joiner{
	char time[90],accept[100];
	int signal,p;
};
int main()
{
	int N,G,C,S,M;
	joiner j[130];
	while(1)
	{
	cin>>N>>G>>S>>C>>M;
	if(N==0&&N==0&&G==0&&S==0&&M==0)
          break;
	for(int i=0;i<N;i++)
	{	
		cin>>j[i].p>>j[i].time;
		j[i].signal=i;	     //signal 為原來在陣列中的順序標記
	}
	  for(int i=0;i<N-1;i++)    //一個選擇排序完成排名
	  {
	  	  for(int k=i;k<N;k++)
	  	  {
	  	  	if(j[i].p<j[k].p)
	  	  	{
	  	  		joiner temp;
	  	  		temp = j[i];
	  	  		j[i] = j[k];
	  	  		j[k] = temp;
				}
			if(j[i].p==j[k].p&&strcmp(j[i].time,j[k].time)>0)
			{
				joiner temp;
	  	  		temp = j[i];
	  	  		j[i] = j[k];
	  	  		j[k] = temp;
			}
			}
	  }
	  for(int i=0;i<N;i++)     
	  {
	  	if(i>=0&&i<G)
	  	{
	  		if(j[i].signal==M-1)
	  		cout<<"Accepted today? I've got a golden medal :)"<<endl;
		  }
		  if(i>=G&&i<G+S)
	  	{
	  		if(j[i].signal==M-1)
	  		cout<<"Accepted today? I've got a silver medal :)"<<endl;
		  }
		  if(i>=G+S&&i<G+S+C)
	  	{
	  		if(j[i].signal==M-1)
	  		cout<<"Accepted today? I've got a copper medal :)"<<endl;
		  }
		  if(i>=G+S+C)
	  	{
	  		if(j[i].signal==M-1)
	  		cout<<"Accepted today? I've got an honor mentioned :)"<<endl;
		  }
	  }
	}
	return 0;
}

這道題理解了題意還是蠻好做的,剛開始還以為每個參賽者都需要輸出結果,後來才發現題目中的M是輸出第幾個參賽者成績的意思。~~