# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
659145 | zhing_zhou | Timovi (COCI18_timovi) | Java | 0 ms | 0 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.
import java.util.*;
public class JuniorPrelims1
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), k = sc.nextInt(), m = sc.nextInt();
int var1 = m / (2 * n * k);
int a[] = new int[n];
for(int i = 0; i < n; i++)
{
a[i] = (2 * k) * var1;
}
m -= (2 * n * k) * var1;
int dir = 1, pos = 0;
while(m != 0)
{
a[pos] += Math.min(k, m);
m -= Math.min(m, k);
pos += dir;
if(pos == n)
{
dir = -1;
pos += dir;
pos += dir;
}
}
for(int i = 0; i < n; i++)
{
System.out.print(a[i] + " ");
}
System.out.println();
}
}