답안 #780054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780054 2023-07-12T06:12:03 Z vjudge1 Timovi (COCI18_timovi) C++17
80 / 80
15 ms 2920 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define pb push_back
#define N 200005
int main(){
	lalala;
	ll int n,x,k;cin>>n>>x>>k;
	ll int arr[n];
	for(int i=0;i<n;i++){
		if(k>=x) arr[i]=x;
		else if(k>0)arr[i]=k;
		else arr[i]=0;
		k-=x;
	}
	if(k<=0){
		for(int i=0;i<n;i++)cout<<arr[i]<<" ";
		cout<<endl;
		return 0;
	}
	ll int hedef=k/((n-1)*x);
	k-=(hedef*x*(n-1));
	for(int i=1;i<n-1;i++)arr[i]+=(hedef*x);
	arr[0]+=(hedef+1)/2*x;
	arr[n-1]+=(hedef/2)*x;
	if(k>0){
		if(hedef%2==0){
			for(int i=n-2;i>-1;i--){
				if(k<=0)break;
				if(k<x)arr[i]+=k;
				else arr[i]+=x;
				k-=x;
			}
		}
		else{
			for(int i=1;i<n;i++){
				if(k<=0)break;
				if(k<x)arr[i]+=k;
				else arr[i]+=x;
				k-=x;
			}
		}
	}
	for(int i=0;i<n;i++)cout<<arr[i]<<" ";
	cout<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 13 ms 2276 KB Output is correct
4 Correct 11 ms 2260 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 12 ms 2792 KB Output is correct
8 Correct 15 ms 2920 KB Output is correct