QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694357#7744. ElevatorAlways#Compile Error//C++23765b2024-10-31 17:46:272024-10-31 17:46:30

Judging History

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

  • [2024-10-31 17:46:30]
  • 评测
  • [2024-10-31 17:46:27]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
//#define int long long 
using namespace std;
long long n,k;
struct node{
	long long num,val,cos;
}e[100005];
bool cmp(node x,node y)
{
	return x.cos>y.cos;
}
int main()
{
	long long T;
	cin>>T;
	for(long long i=1;i<=T;i++)
	{
		cin>>n>>k;
	long long 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);
	long long ans=0;
	long long i=1;
	long long v=0;
	long long 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;
	}
	
	  }

詳細信息

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