# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1005291 | ErJ | Measures (CEOI22_measures) | C++17 | 27 ms | 6040 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>
using namespace std;
#define ll long long
#define vi vector<ll>
#define pp pair<ll, ll>
#define vp vector<pp>
#define vvi vector<vi>
#define inf 1000000000000000
#define rep(i,n) for(int i = 0; i < n; i++)
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int n, m;
ll d;
cin >> n >> m >> d;
d *= 2;
vi A(m);
rep(i,m) {
cin >> A[i];
A[i] *= 2;
}
//cin >> A[0];
// A[0] *=2;
vp dp(m);
dp[0] = {0, A[0]};
for(int i = 1; i < m; i++){
//cin >> A[i];
//A[i] *= 2;
ll pos = A[i] + dp[i - 1].first;
pos = min(pos, max(dp[i - 1].second + d, A[i] - dp[i-1].first));
ll plus = (dp[i-1].second + d - pos) / 2;
if(plus < 0) plus = 0;
dp[i] = {dp[i-1].first + plus, pos + plus};
//cout << dp[i].first / 2 << endl;
}
rep(i, dp.size()){
cout << dp[i].first / 2 << " ";
}
cout << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |