Submission #1233624

#TimeUsernameProblemLanguageResultExecution timeMemory
123362412baaterHorses (IOI15_horses)C++20
17 / 100
1596 ms8244 KiB
#include "horses.h" #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() { int partitionStart = 0; int lastPartitionStart = 0; ll horsesAtPartitionStart = 1; ll auxHorses = 1; ll horses = 1; ll profit = 0; for (int i = 0; i < n; i++) { horses *= x[i]; if (horses > MOD) { horsesAtPartitionStart = auxHorses; lastPartitionStart = partitionStart; partitionStart = i; horses %= MOD; auxHorses = horses; } } horses = horsesAtPartitionStart; for (int i = lastPartitionStart; i < n; i++) { horses *= x[i]; profit = max(profit, horses*y[i]); } return profit%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...