牛客小白月赛85 E.烙饼

牛客小白月赛85 E.烙饼_第1张图片

主要是学一下它的这个构造方法~看题不仔细 直接脑瘫

#include
using namespace std;
using ll = long long;
const int N = 1e5+10;
ll a[N],b[N];
ll n,m;
ll sum;
ll ans;


priority_queue,vector>,greater>>q;
void solve()
{
	cin>>n>>m;
	
	for(int i=1;i<=n;i++){
		cin>>a[i];
		q.push({a[i],i});
		sum+=a[i];ans = max(ans,a[i]);
	}
	
	ans = max((sum+m-1)/m,ans);
	
	
	vector>v;
	for(int i=1;i<=m;i++){
		if(!q.size())break;
		
		while(b[i]

#include
using namespace std;
using ll = long long;
const int N = 1e5+10;
ll a[N];
ll n,m;
ll sum;
ll ans;


void solve()
{
	cin>>n>>m;
	
	for(int i=1;i<=n;i++){
		cin>>a[i];
		
		sum+=a[i];ans = max(ans,a[i]);
	}
	
	ans = max((sum+m-1)/m,ans);
	
	
	ll b = 1;
	vector>v;
	
	for(int i=1;i<=m;i++){
		ll rem = ans;
		while(b<=n&&rem){
			ll tem = min(a[b],rem);
			v.push_back({b,i,ans-rem,ans-rem+tem});
			rem-=tem,a[b]-=tem;
			if(!a[b])b++;
		}
	}
	
	cout<

你可能感兴趣的:(思维,模拟,算法,c++,职场和发展)