답안 #636702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636702 2022-08-30T00:15:10 Z Ahmed_Solyman Timovi (COCI18_timovi) C++14
30 / 80
18 ms 3092 KB
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define sz size()
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"YES":"NO")<<endl;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast
    ll n,k,m;cin>>n>>k>>m;
    ll x=0;
    ll g=m;
    if(k*n<=g){
    	g-=k*n;
    	x++;
    	x+=g/(k*(n-1));
    }
    if(!x){
    	vector<ll>ans(n);
    	for(ll i=0;i<n;i++){
    		if(m<k){
    			ans[i]=m;
    			m=0;
    		}
    		else{
    			ans[i]=k;
    			m-=k;
    		}
    	}
    	for(auto i:ans)cout<<i<<" ";
    	return 0;
    }
    vector<ll>ans(n);
    if(x%2==0){
    	ll f=0;
    	for(ll i=0;i<n;i++){
    		ans[i]=k;
    		f+=k;
    	}
    	ll r=(m-f)/(n-1);
    	for(int i=n-2;i>=0;i--){
    		ll u=r/2+r%2;
    		ans[i]+=u*k;
    		f+=u*k;
    	}
    	for(int i=1;i<n;i++){
    		ll u=r/2;
    		ans[i]+=u*k;
    		f+=u*k;
    	}
    	ll y=m-f;
    	for(ll i=(ans[0]>0);i<n;i++){
    		if(y){
    			if(y>=k){
    				y-=k;
    				ans[i]+=k;
    			}
    			else{
    				ans[i]+=y;
    				y=0;
    			}
    		}
    	}
    }
    else{
    	ll f=0;
    	for(ll i=0;i<n;i++){
    		ans[i]=k;
    		f+=k;
    	}
    	ll r=(m-f)/(n-1);
    	if(r){
	    	for(int i=n-2;i>=0;i--){
	    		ll u=r/2+r%2;
	    		ans[i]+=u*k;
	    		f+=u*k;
	    	}
	    	for(int i=1;i<n;i++){
	    		ll u=r/2;
	    		ans[i]+=u*k;
	    		f+=u*k;
	    	}
    	}
    	ll y=m-f;
    	for(ll i=n-2;i>=0;i--){
    		if(y){
    			if(y>=k){
    				y-=k;
    				ans[i]+=k;
    			}
    			else{
    				ans[i]+=y;
    				y=0;
    			}
    		}
    	}
    }
    for(auto i:ans){
    	cout<<i<<" ";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Correct 14 ms 2256 KB Output is correct
4 Correct 14 ms 2288 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Incorrect 16 ms 2804 KB Output isn't correct
8 Incorrect 18 ms 3092 KB Output isn't correct