Submission #49829

# Submission time Handle Problem Language Result Execution time Memory
49829 2018-06-03T11:41:27 Z A_H_Ghaznavi Timovi (COCI18_timovi) C++14
80 / 80
52 ms 3124 KB
// In the name of god
// A.H.Ghaznavi
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n,k,m,ans[200010],bag1,bag2,mtk,w,x;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k>>m;
    mtk=m/k;
    w=m%k;
    if (n*k>=m)
    {
        for (ll i=0;i<mtk;i++)
            ans[i]=k;
        ans[mtk]=w;
        for (ll i=0;i<n;i++)
            cout<<ans[i]<<" ";
        return 0;
    }
    mtk-=n;
    for (ll i=1;i<=n;i++)
        ans[i]=k;
    bag1=mtk/(n-1);
    bag2=mtk%(n-1);
    if (bag1%2==0)
    {
        if (n!=2)
        {
            for (ll i=2;i<=n-1;i++)
                ans[i]+=bag1*k;
        }
        ans[1]+=(bag1*k)/2;
        ans[n]+=(bag1*k)/2;
        if (bag2)
        {
            for (ll i=n-1;i>=n-bag2;i--)
                ans[i]+=k;
        }
        ans[n-bag2-1]+=w;
        for (ll i=1;i<=n;i++)
            cout<<ans[i]<<" ";
        return 0;
    }
    if (n!=2)
    {
        for (ll i=2;i<=n-1;i++)
            ans[i]+=bag1*k;
    }
    ans[1]+=((bag1+1)/2)*k;
    ans[n]+=(bag1/2)*k;
    for (ll i=2;i<=bag2+1;i++)
        ans[i]+=k;
    ans[bag2+2]+=w;
    for (ll i=1;i<=n;i++)
        cout<<ans[i]<<" ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 17 ms 888 KB Output is correct
4 Correct 16 ms 888 KB Output is correct
5 Correct 2 ms 888 KB Output is correct
6 Correct 2 ms 888 KB Output is correct
7 Correct 20 ms 2992 KB Output is correct
8 Correct 52 ms 3124 KB Output is correct