当前位置: 代码迷 >> 综合 >> poj 2497 Strategies 模拟水题
  详细解决方案

poj 2497 Strategies 模拟水题

热度:5   发布时间:2024-01-19 05:43:35.0

水题,直接贴代码。

//poj 2497
//sep9
#include <iostream>
#include <algorithm>
using namespace std;
int a[32];
int main()
{int cases,c=0;scanf("%d",&cases);while(cases--){int tot,n;scanf("%d%d",&tot,&n);	int x2,y2,t;for(int i=0;i<n;++i)scanf("%d",&a[i]);x2=0,y2=0,t=0;sort(a,a+n);while(x2<n&&t+a[x2]<=tot){y2+=t+a[x2];		t+=a[x2];++x2;}printf("Scenario #%d:\nSteve wins with %d solved problems and a score of %d.\n\n",++c,x2,y2);}return 0;	
}