Submission #738675

#TimeUsernameProblemLanguageResultExecution timeMemory
738675fractlpacaHorses (IOI15_horses)C++17
0 / 100
1572 ms9260 KiB
#include "horses.h" #include <vector> #include <algorithm> #define v vector #define MOD 1000000007 using namespace std; v<int> xs; v<int> ys; int n; // Subtask 1 // int solve() { // int ma = 0; // int pop = 1; // for(int i=0; i<n; i++) { // pop*=xs[i]; // ma = max(ma, pop*ys[i]); // } // return ma%MOD; // } // int init(int N, int X[], int Y[]) { // n = N; // for (int i=0; i<n; i++) { // xs.push_back(X[i]); // ys.push_back(Y[i]); // } // return solve(); // } // int updateX(int pos, int val) { // xs[pos] = val; // return solve(); // } // int updateY(int pos, int val) { // ys[pos] = val; // return solve(); // } // Subtask 2 int solve() { int max_i = n-1; int pop = 1; for(int i=n-2; i>=0; i--) { if (ys[i] > ys[max_i]*pop) { max_i = i; pop=1; } pop = min(MOD, pop*xs[i]); } pop=1; for(int i=0; i<=max_i; i++){ pop = (pop*xs[i])%MOD; } return (pop*ys[max_i])%MOD; } int init(int N, int X[], int Y[]) { n = N; for (int i=0; i<n; i++) { xs.push_back(X[i]); ys.push_back(Y[i]); } return solve(); } int updateX(int pos, int val) { xs[pos] = val; return solve(); } int updateY(int pos, int val) { ys[pos] = val; return solve(); }
#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...