QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694307#7744. Elevatorsix_sspCompile Error//C++23712b2024-10-31 17:41:132024-10-31 17:41:14

Judging History

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

  • [2024-10-31 17:41:14]
  • 评测
  • [2024-10-31 17:41:13]
  • 提交

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;
	}
	
	  }

详细

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++)
      |                 ^