답안 #739103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739103 2023-05-10T00:15:47 Z mzv Timovi (COCI18_timovi) C++17
80 / 80
14 ms 1876 KB
#include <bits/stdc++.h>

#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

/* ------------------------ hi lol ------------------------ */

ll n,k,m,arr[200001],def,le,ri,i;

int main() {
    ccd
    cin >> n >> k >> m;
    if (m/(n*k)>0) {
    	m-=n*k;
    	def=1+(m/((n-1)*k));
    	le=(def/2)+1;
    	ri=(def/2)+(def%2);
    	m-=(def-1)*((n-1)*k);
    }
    // tentuin nilai def,le,ri, sama sisa orng (m), baru lanjut
    // cout << def << " " << le << " " << ri << " " << m << endl;
    while (m>0) {
    	if (def==0) {
    		i=1;
    		while (m-k>=0) {
    			arr[i]=k;
    			m-=k;
    			i++;
    		}
    	}
    	else if (def%2==0) {
    		i=2;
    		while (m-k>=0) {
    			arr[i]=k;
    			m-=k;
    			i++;
    		}
    	}
    	else {
    		i=n-1;
    		while (m-k>=0) {
    			arr[i]=k;
    			m-=k;
    			i--;
    		}
    	}
    	arr[i]=m;
    	break;
    }
    cout << (arr[1]+(le*k)) << " ";
    for (int i=2;i<n;i++) {
    	cout << (arr[i]+(def*k)) << " ";
    }
    cout << (arr[n]+(ri*k)) << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 12 ms 784 KB Output is correct
4 Correct 12 ms 724 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 14 ms 1468 KB Output is correct
8 Correct 13 ms 1876 KB Output is correct