• POJ 2497 Strategies (待解决)


    题目链接:http://poj.org/problem?id=2497

    题目大意:

    有三个人做题,但是他们做同一道题的所用的时间相同,但是他们做题的顺序不同,在计分时,按照如下的方式进行计分:

    The score for a single problem is the time in minutes from start of the contest until you solve it. The overall score is the sum of scores of the problems you solved.

    而获胜者的归属按照下面的规则进行:

    The winner is the one who solved the most problems, and in case of a tie, the one with the lowest score. If there's still a tie, then they agree that Steve wins because he always brings delicious apple pie.

    #include <iostream>
    #include <algorithm>
    #include <string>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    using namespace std;
    
    
    
    int main()
    {
    	int count = 1;
    	int group;
    	scanf("%d",&group);
    	while(group--){
    		int  time ,ccase, firnu[30],i;
    		scanf("%d%d",&time,&ccase);
    		for(i=0;i<ccase;i++)
    			scanf("%d",&firnu[i]);
    		int Bill=0,Billsum=0, Steve=0, Stevesum=0, Linus =0,Linussum=0, a=0,b=0,c=0;//Bill=0, Steve=0,Linus =0,记录三个人的总分,Billsum=0, Stevesum=0, Linussum=0则分别记录他们做完的题到现在的时间,也就是从开始到现在的时间
    		i=0;
    		while((Billsum+firnu[i])<=time && i<ccase){///以下分别计算三个人的分数
    			Bill=Bill+firnu[i]+Billsum;
    			Billsum=Billsum+firnu[i];
    			i++;
    			a++;
    		}
    		sort(firnu,firnu+ccase);		i=0;
                      while((Stevesum+firnu[i])<=time && i<ccase){
    			Steve=Steve+firnu[i]+Stevesum;
    			Stevesum=Stevesum+firnu[i];
    			i++;
    			b++;
    		}
    		i=ccase-1;
    		while((Linussum+firnu[i])<=time && i>=0){
    			Linus=Linus+firnu[i]+Linussum;
    			Linussum=Linussum+firnu[i];
    			i--;
    			c++;
    		}
    
    		int max,solve;
    		string maxname;
    		if(b>a||(b==a && Steve<=Bill) ){
    
    			max=Steve;
    			solve=b;
    			maxname="Steve";
    		}
    		else{
    			max=Bill;
    			solve=a;
    			maxname="Bill";
    		}
    		if(c>solve||(c==solve&&Linus<max)){
    			max=Linus;
    			solve=c;
    			maxname="Linus";
    		}
    
    	  //	cout<<"B "<<a<<" solved problems and a score of "<<Bill<<"    "<<Billsum<<"
    ";该处亟待解决,用printf的时候输不出正确的结果,可能是使用的问题
    	  //	cout<<"S "<<b<<" solved problems and a score of "<<Steve<<"    "<<Stevesum<<"
    ";
               //	cout<<"L "<<c<<" solved problems and a score of "<<Linus<<"    "<<Linussum<<"
    
    ";
    		//	cout<<"aaaaaaaaaaaaaaaaaaaaaaaaa"<<endl;
    		//printf("Scenario #%d:
    ",&count);
    		cout<<"Scenario #"<<count<<":"<<endl;
    		cout<<maxname;
    		cout<<" wins with "<<solve<<" solved problems and a score of "<<max<<".
    
    ";
    	//	printf(" wins with %d solved problems and a score of %d
    
    ",&solve,&max);
    			count++;
    	}
    
    	return 0;
    }
    


     

  • 相关阅读:
    十大开源CRM
    EL表达式【转】
    zk调用js(转)
    MVC4学习笔记(三) 数据验证设计
    MVC4学习笔记(一) 认识MVC
    MVC4学习笔记(四) MVC界面设计
    hibernate介绍
    如何在oracle中导入dmp数据库文件
    JS的delete操作
    使用JavaScript给Html元素加边框
  • 原文地址:https://www.cnblogs.com/zswbky/p/5432031.html
Copyright © 2020-2023  润新知