# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780050 | vjudge1 | Timovi (COCI18_timovi) | C++17 | 12 ms | 2888 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |