# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
596988 | PiejanVDC | Horses (IOI15_horses) | C++17 | 1562 ms | 10464 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 "horses.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>x,y;
int init(int n, int X[], int Y[]) {
for(int i = 0 ; i < n ; i++)
x.push_back(X[i]), y.push_back(Y[i]);
int last = -1;
long long got = 1;
long long ans = 0;
long long curr = 0;
long long prev = -1;
while(last < n-1) {
for(int i = last+1 ; i < n ; i++) {
got *= x[i];
if(y[i] * (got-1) > prev)
last = i, prev = y[i] * (got-1);
// + case where you sell all of them
ans = max(ans, curr + y[i] * got);
}
curr += prev;
prev = -1;
got = 1;
}
ans = max(ans, curr);
return ans;
}
int updateX(int p, int val) {
int n = (int)x.size();
x[p] = val;
int last = -1;
long long got = 1;
long long ans = 0;
long long curr = 0;
long long prev = -1;
while(last < n-1) {
for(int i = last+1 ; i < n ; i++) {
got *= x[i];
if(y[i] * (got-1) > prev)
last = i, prev = y[i] * (got-1);
// + case where you sell all of them
ans = max(ans, curr + y[i] * got);
}
curr += prev;
prev = -1;
got = 1;
}
ans = max(ans, curr);
return ans;
}
int updateY(int p, int val) {
int n = (int)x.size();
y[p] = val;
int last = -1;
long long got = 1;
long long ans = 0;
long long curr = 0;
long long prev = -1;
while(last < n-1) {
for(int i = last+1 ; i < n ; i++) {
got *= x[i];
if(y[i] * (got-1) > prev)
last = i, prev = y[i] * (got-1);
// + case where you sell all of them
ans = max(ans, curr + y[i] * got);
}
curr += prev;
prev = -1;
got = 1;
}
ans = max(ans, curr);
return ans;
}
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... |