萌新求助橙题一道,WA50pts
查看原帖
萌新求助橙题一道,WA50pts
552298
Greenzhe楼主2022/4/22 19:04

RT

Problem

Record

Code:

#include <bits/stdc++.h>
using namespace std;

inline int qread(){
	int s=0,f=1;
	char ch=getchar();
	while('0'>ch||ch>'9'){
		if(ch=='-') f=-1; 
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		s=(s<<1)+(s<<3)+(ch-48);
		ch=getchar();
	}
	return s*f;
}
inline void qwrite(int p){
	if(p<0){
		putchar('-');
		p=-p;
	}
	if(p>9) qwrite(p/10);
	putchar(p%10+48);
}

int n,a[10005],b[10005];
void solve(){
	n=qread();
	for(int i=1;i<=n;++i) a[i]=qread();
	int last=0;
	memset(b,0,sizeof(b));
	a[n+1]=n+1;
	for(int i=1;i<=n+1;++i){
		if(a[i]!=-1){
			int tot=a[i]-a[last];
			for(int j=last+1;j<=i;++j) b[j]=tot/(i-last);
			b[i]+=tot%(i-last);
			last=i;
		}
	}
	for(int i=1;i<=n;++i){
		qwrite(b[i]);
		putchar(' ');
	}
	putchar('\n');
}
int main(){
	int T=qread();
	while(T--)
		solve();
	return 0;
}

的确平均分了啊,为神马还 WA

2022/4/22 19:04
加载中...