QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290137#7964. 转化daydream#Compile Error//C++201.4kb2023-12-24 14:09:302023-12-24 14:09:31

Judging History

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

  • [2023-12-24 14:09:31]
  • 评测
  • [2023-12-24 14:09:30]
  • 提交

answer

#include<bits/stdc++.h>
#define db double
#define LL long long
#define pb push_back
#define eb emplace_back
#define pli pair<LL,int>
#define pii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
using namespace std;
const int dx[]={0,1,0,-1,1,1,-1,-1},
		  dy[]={1,0,-1,0,1,-1,1,-1};

int n;
void solve()
{
	cin>>n;vector<int> a(n+1),b(n+1),c(n+1),ex(n+1);
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<=n;++i) cin>>b[i];
	for(int i=1;i<=n;++i) cin>>c[i];
	LL sum1=0,sum2=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]) a[i]+=c[i],c[i]=0,sum1+=min(a[i],b[i]);
		else if(b[i]&&c[i]) sum2+=max(0,min(b[i]-1,c[i]));
	}
	for(int i=1;i<=n;++i)
	{
		LL ans=sum1+a[i]-min(a[i],b[i]);
		if(sum1) ans+=sum2;
		if(!a[i]) ans+=c[i]-max(0,min(b[i]-1,c[i]));
		cout<<ans<<' ';
	}
	cout<<'\n';
	vector<int> ps(n+1);
	for(int i=1;i<=n;++i) ps[i]=i;
	sort(ps.begin()+1,ps.end(),[&](const int &x,const int &y)
	{
		if(a[x]!=a[y]) return a[x]>a[y];
		int nx=min(b[x],c[x]+1),ny=min(b[y],c[y]+1)
		if(nx!=ny) return nx>ny;
		return c[x]>c[y];
	});
	LL sum=0,ans=0;
	for(int x=1;x<=n;++x)
	{
		int i=ps[x];
		if(a[i])
		{
			ans+=a[i];
			sum+=min(a[i],b[i]);
		}
		else if(sum)
		{
			sum--;
			ans+=c[i];
			sum+=min(b[i],c[i]+1);
		}
	}
	cout<<ans<<'\n';
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int TT=1;
//	cin>>TT;
	for(;TT;--TT) solve();
	return 0;
}

Details

answer.code: In lambda function:
answer.code:42:17: error: expected ‘,’ or ‘;’ before ‘if’
   42 |                 if(nx!=ny) return nx>ny;
      |                 ^~