QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#694277#7744. Elevatorsix_sspCompile Error//C++14712b2024-10-31 17:38:432024-10-31 17:38:44

Judging History

你现在查看的是最新测评结果

  • [2024-10-31 17:38:44]
  • 评测
  • [2024-10-31 17:38:43]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long 
using namespace std;
int n,k;
struct node{
	int num,val,cos;
}e[100005];
bool cmp(node x,node y)
{
	return x.cos>y.cos;
}
signed main()
{
	int T;
	cin>>T;
	for(int i=1;i<=T;i++)
	{
		cin>>n>>k;
	int he=0;
	for(int i=1;i<=n;i++)
	{
		cin>>e[i].num>>e[i].val>>e[i].cos;
		he+=e[i].num*e[i].val;
	}
	sort(e+1,e+1+n,cmp);
	int ans=0;
	int i=1;
	int v=0;
	int co=e[i].cos;
	while(he>k)
	{
		v+=e[i].val;
		e[i].num--;
		if(v>k)
		  {
		  	he-=v;
		  	he+=e[i].val;
		  	v=e[i].val;
		  	ans+=co;
		  	co=e[i].cos;
		  }
		if(e[i].num==0)
		  i++; 
	}
	ans+=co;
	cout<<ans<<endl;
	}
	
	  }

Details

answer.code: In function ‘int main()’:
answer.code:29:13: error: redeclaration of ‘long long int i’
   29 |         int i=1;
      |             ^
answer.code:18:17: note: ‘long long int i’ previously declared here
   18 |         for(int i=1;i<=T;i++)
      |                 ^