Submission #780050

#TimeUsernameProblemLanguageResultExecution timeMemory
780050vjudge1Timovi (COCI18_timovi)C++17
30 / 80
12 ms2888 KiB
#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){ 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...