Submission #98245

#TimeUsernameProblemLanguageResultExecution timeMemory
98245dalgerokTimovi (COCI18_timovi)C++17
80 / 80
30 ms2944 KiB
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n, k, m; cin >> n >> k >> m; int a[n + 1]; memset(a, 0, sizeof(a)); for(int i = 1; i <= n; i++){ a[i] = (m >= k ? k : m); m -= (m >= k ? k : m); } int val = m / ((n - 1) * k); m %= ((n - 1) * k); for(int i = 1; i < n; i++){ a[i] += ((val + 1) / 2) * k; } for(int i = n; i > 1; i--){ a[i] += (val / 2) * k; } if(val % 2 == 1){ for(int i = 2; i <= n; i++){ a[i] += (m >= k ? k : m); m -= (m >= k ? k : m); } } else{ for(int i = n - 1; i >= 1; i--){ a[i] += (m >= k ? k : m); m -= (m >= k ? k : m); } } for(int i = 1; i <= n; i++){ cout << a[i] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...