Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- const int N = 1005;
- int n, m;
- int a[N];
- void solve() {
- a[0] = 0;
- for(int i = 1; i <= n; ++i)
- if(a[i] == -1) {
- a[i] = a[i-1] + m;
- }
- for(int i = 1; i <= n; ++i)
- if(a[i] - a[i-1] < m) {
- cout << -1 << ' ';
- return;
- }
- for(int i = 1; i <= n; ++i)
- cout << a[i] - a[i-1] << ' ';
- }
- int main() {
- //freopen("in.txt", "r", stdin);
- freopen("STONES.inp", "r", stdin);
- freopen("STONES.out", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(NULL); cout.tie(NULL);
- cin >> n >> m;
- for(int i = 1; i <= n; ++i)
- cin >> a[i];
- solve();
- return 0;
- }
Add Comment
Please, Sign In to add comment