제출 #529215

#제출 시각아이디문제언어결과실행 시간메모리
529215Cyanmond말 (IOI15_horses)C++17
0 / 100
1517 ms14148 KiB
// clang-format off #include <bits/stdc++.h> using i64 = int64_t; namespace mycode { int N; std::vector<int> X, Y; constexpr i64 mod = 1000000007; constexpr int max_v = 1000000000; void mul(i64 &v, i64 d) { v = v * d % mod; } int calc() { i64 v = 1; double best = (double)(Y[N - 1]); int best_pos = N - 1; for (int i = N - 2; i >= 0; --i) { v *= X[i + 1]; if ((double)Y[i] / (double)v >= best) { best = (double)Y[1] / (double)v; best_pos = i; } if (v > max_v) break; } i64 ret = 1; for (int i = 0; i <= best_pos; ++i) { mul(ret, X[i]); } mul(ret, Y[best_pos]); return (int)ret; } int init(int n, std::vector<int> x, std::vector<int> y) { N = n; X = std::move(x); Y = std::move(y); return calc(); } int updateX(int pos, int val) { X[pos] = val; return calc(); } int updateY(int pos, int val) { Y[pos] = val; return calc(); } } int init(int N, int X[], int Y[]) { std::vector<int> x(N), y(N); for (int i = 0; i < N; ++i) { x[i] = X[i]; y[i] = Y[i]; } return mycode::init(N, x, y); } int updateX(int pos, int val) { return mycode::updateX(pos, val); } int updateY(int pos, int val) { return mycode::updateY(pos, val); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...