# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
739103 | mzv | Timovi (COCI18_timovi) | C++17 | 14 ms | 1876 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>
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |