#include "bits/stdc++.h"
#define endl '\n'
#define trav(var, begin, end) for(auto var = begin; var < end; ++var)
#define travi(var, begin, end) for(auto var = begin-1; var >= end; --var)
#define travd(var, begin, end, delta) for(auto var = begin; var < end; var += delta)
#define travdi(var, begin, end, delta) for(auto var = begin-1; var >= end; var -= delta)
#pragma GCC optimize ("Ofast")
using namespace std;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;
using ushort = unsigned short;
using uchar = unsigned char;
const int inf = 987654321;
const int bigprime = int(2e9 + 11);
const ld pi = acosl(-1);
const double eps = 1e-12;
const int dirs[4][2] = { { 1, 0 },{ 0, 1 },{ -1, 0 },{ 0, -1 } };
int main()
{
cin.sync_with_stdio(false), cin.tie(nullptr);
cout << fixed << setprecision(10);
ll n, j, r, t;
cin >> n >> j >> r >> t;
ll arr[100001] = { 0, };
trav(i, 1, n + 1)
arr[i] = j;
int top = 1;
int bottom = 2;
trav(i, 0, t)
{
swap(arr[n], arr[bottom]);
travi(k, bottom, top)
{
arr[k + 1] += arr[k] / r + !!(arr[k] % r);
arr[k] -= arr[k] / r + !!(arr[k] % r);
//arr[k] = arr[k - 1] / r + !!(arr[k - 1] % r) + arr[k] * (r - 1) / r;
}
swap(arr[n], arr[bottom]);
bottom = min(bottom + 1, (int)n);
if (!arr[top])
top++;
if (top >= n)
break;
}
trav(i, 1, n + 1)
cout << arr[i] << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1144 KB |
Output is correct |
2 |
Correct |
3 ms |
1220 KB |
Output is correct |
3 |
Correct |
3 ms |
1220 KB |
Output is correct |
4 |
Correct |
4 ms |
1268 KB |
Output is correct |
5 |
Correct |
3 ms |
1292 KB |
Output is correct |
6 |
Correct |
4 ms |
1300 KB |
Output is correct |
7 |
Correct |
23 ms |
1300 KB |
Output is correct |
8 |
Correct |
12 ms |
1300 KB |
Output is correct |
9 |
Correct |
42 ms |
1552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1144 KB |
Output is correct |
2 |
Correct |
3 ms |
1220 KB |
Output is correct |
3 |
Correct |
3 ms |
1220 KB |
Output is correct |
4 |
Correct |
4 ms |
1268 KB |
Output is correct |
5 |
Correct |
3 ms |
1292 KB |
Output is correct |
6 |
Correct |
4 ms |
1300 KB |
Output is correct |
7 |
Correct |
23 ms |
1300 KB |
Output is correct |
8 |
Correct |
12 ms |
1300 KB |
Output is correct |
9 |
Correct |
42 ms |
1552 KB |
Output is correct |
10 |
Execution timed out |
2037 ms |
1552 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |