이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define lso(x) x&(-x)
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
vi X, Y, T;
int n, N;
ll get() {
int start = n - 1;
ll pr = X[start];
while (pr < 2*1e9) {
start--;
if (start == 0) break;
pr *= X[start];
}
T.assign(n, 1);
rep(i, start, n) {
if (i == 0) T[i] = X[i];
else T[i] = T[i - 1] * X[i];
}
ll best = 0;
rep(i, start, n) {
best = max(best, T[i] * Y[i]);
}
best = best % 1000000009;
ll mult_prev = 1;
rep(i, 0, start) mult_prev = (mult_prev * X[i]) % 1000000009;
best = (best * mult_prev) % 1000000009;
return best;
}
int init(int a, int x[], int y[]) {
n = N = a;
X.resize(N); Y.resize(N); T.resize(N);
rep(i,0,N) X[i] = x[i];
rep(i,0,N) Y[i] = y[i];
return get();
}
int updateX(int pos, int val) {
X[pos] = val;
return get();
}
int updateY(int pos, int val) {
Y[pos] = val;
return get();
}
// int main() {
// int x[] = {1, 1, 1, 1, 2};
// int y[] = {1, 2, 3, 4, 5};
// cout << init(5, x, y);
// }
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'll get()':
horses.cpp:19:10: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
19 | while (pr < 2*1e9) {
| ^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:48:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
48 | return get();
| ~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:53:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
53 | return get();
| ~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:58:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
58 | return get();
| ~~~^~
# | 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... |