답안 #696389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
696389 2023-02-06T11:12:30 Z duyyy Timovi (COCI18_timovi) C++14
80 / 80
17 ms 2888 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,k,m,a,b;
    cin>>n>>k>>m;
    long long kq[n+1];
    memset(kq,0,sizeof(kq));
    a=m/k,b=m%k;
    if(a<n) for(int i=1;i<=a+1;i++) if(m>k) {kq[i]=k;m-=k;}
                                      else {kq[i]=m;break;}
    else{
        m-=n*k;
        for(int i=1;i<=n;i++) kq[i]=k;
        long long c=m/((n-1)*k),l,r;
        l=(c+1)/2;r=c/2;
        kq[1]+=(k*l);
        kq[n]+=(k*r);
        for(int i=2;i<n;i++) kq[i]+=(c*k);
        m-=c*(n-1)*k;
        if(c%2==0){
            for(int i=n-1;i>0;i--)
            if(m>k) {kq[i]+=k;m-=k;}
            else {kq[i]+=m;break;}
        }
        else{
            for(int i=2;i<=n;i++)
            if(m>k) {kq[i]+=k;m-=k;}
            else {kq[i]+=m;break;}
        }
    }
    for(int i=1;i<=n;i++) cout<<kq[i]<<' ';
    return 0;
}

Compilation message

timovi.cpp: In function 'int main()':
timovi.cpp:4:23: warning: variable 'b' set but not used [-Wunused-but-set-variable]
    4 |     long long n,k,m,a,b;
      |                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 15 ms 2260 KB Output is correct
4 Correct 16 ms 2260 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 17 ms 2876 KB Output is correct
8 Correct 17 ms 2888 KB Output is correct