Submission #1233714

#TimeUsernameProblemLanguageResultExecution timeMemory
123371412baaterHorses (IOI15_horses)C++20
34 / 100
1596 ms8256 KiB
#include "horses.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; const ll MOD = 1E9 + 7; const int MAXN = 500050; int n; vector<int> x(MAXN); vector<int> y(MAXN); int solve() { ll bestInd = n-1; ll tot = x[n-1]; for (int i = n-2; i >= 0; i--) { if (tot*y[bestInd] < y[i]) { bestInd = i; tot = 1; } tot *= x[i]; if (tot > 1000000000) { break; } } // cout << bestInd << " : \n"; ll profit = 0; ll horses = 1; for (int i = 0; i <= bestInd; i++) { horses *= x[i]; horses %= MOD; } return (horses*y[bestInd])%MOD; } int init(int N, int X[], int Y[]) { n = N; for (int i = 0; i < N; i++) { x[i] = X[i]; y[i] = Y[i]; } return solve(); } int updateX(int pos, int val) { x[pos] = val; return solve(); } int updateY(int pos, int val) { y[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...