# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20676 | Kwiyomi Express (#35) | Can polan into space? (OJUZ11_space) | C++98 | 173 ms | 24720 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 <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int main()
{
int n;
cin >> n;
vector<vector<long long> > cost(n+1, vector<long long>(2));
vector<vector<long long> > from(n, vector<long long>(2));
// 0 : me fly early, 1 : me fly late
cost[0][1] = 0;
cost[0][0] = -9999999999999999LL;
for (int i=0; i<n; i++) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
cost[i+1][0] = max(cost[i][0] + b, cost[i][1] + a);
cost[i+1][1] = max(cost[i][0] + c, cost[i][1] + b);
from[i][0] = (cost[i+1][0] == cost[i][1] + a);
from[i][1] = (cost[i+1][1] == cost[i][1] + b);
}
printf("%lld\n", cost[n][0]);
vector<int> res(n);
int idx = 1;
int ll = 0, rr = 0;
res[n-1] = 0;
for (int i=n-1; i>=1; i--) {
if (from[i][idx] == 1) {
ll --;
res[i-1] = ll;
idx = 1;
} else {
rr ++;
res[i-1] = rr;
idx = 0;
}
}
for (int i=0; i<n; i++)
printf("%d ", res[i]-ll+1);
printf("\n");
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |