# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
961737 | LucaLucaM | 말 (IOI15_horses) | C++17 | 1519 ms | 12180 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "horses.h"
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
#define int ll
const int NMAX = 5e5;
const int mod = 1e9 + 7;
int n;
int x[NMAX + 1], y[NMAX + 1];
int solve() {
ll prod = 1;
bool bigProd = false;
for (int i = 1; i <= n; i++) {
if ((ll) prod * x[i] > 1e9) {
bigProd = true;
break;
}
prod *= x[i];
}
if (bigProd) {
int m = n;
int maxY = 0;
while (m > 0 && x[m] == 1) {
maxY = std::max(maxY, y[m--]);
}
maxY = std::max(maxY, y[m]);
prod = 1;
for (int i = 1; i <= m; i++) {
prod = (ll) prod * x[i] % mod;
}
return (ll) prod * maxY;
}
ll dp[n + 1] = {}; /// dp[i] =def= care e profitul maxim a.i. la finalul celei de a i-a zile am exact 1 cal
for (int i = 1; i <= n; i++) {
int intre = 1;
for (int j = i; j > 0; j--) {
intre *= x[j];
dp[i] = std::max(dp[i], dp[j - 1] + (ll) y[i] * (intre - 1));
}
}
ll ret = 0;
for (int i = 1; i <= n; i++) {
ret = std::max(ret, dp[i] + y[i]);
}
return ret % mod;
}
signed init(signed N, signed X[], signed Y[]) {
n = N;
for (int i = 1; i <= n; i++) {
x[i] = X[i - 1];
y[i] = Y[i - 1];
}
return solve();
}
signed updateX(signed pos, signed val) {
x[++pos] = val;
return solve();
}
signed updateY(signed pos, signed val) {
y[++pos] = val;
return solve();
}
컴파일 시 표준 에러 (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... |