C. Perform Easily

Posted thusloop

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C. Perform Easily相关的知识,希望对你有一定的参考价值。

Perform Easily

//#pragma GCC optimize(2)
//#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int inf=2e18+100;
const int maxn=2e5+100;
int a[maxn],b[maxn];
pii p[maxn*3];
signed main()
{
	int n;
	for(int i=1;i<=6;i++)
	{
		cin>>a[i];
	}
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=6;j++)
		{
			p[(j-1)*n+i]={b[i]-a[j],i};
		}
	}
	sort(p+1,p+6*n+1);
	int l=1,r=1;
	int ans=inf;
	map<int,int>mp;
	while(r<=6*n)
	{
		while(mp.size()<n&&r<=6*n)
		{
			mp[p[r].se]++;	           
			r++;		
		}
		if(mp.size()==n)
		{
			ans=min(ans,p[r-1].fi-p[l].fi);
			mp[p[l].se]--;
			if(mp[p[l].se]==0)mp.erase(mp.find(p[l].se));
			l++;
		}
	}
	cout<<ans<<"\\n";
}

以上是关于C. Perform Easily的主要内容,如果未能解决你的问题,请参考以下文章

NSPersistentContainer,performBackgroundTask,调用perform什么都不做

easy和easily都是副词时,有什么区别?

传递双精度值返回未知值C.

1114 - Easily Readable

love easily fade

[转]Easily Add a Ribbon into a WinForms Application