# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199706 | FieryPhoenix | Horses (IOI15_horses) | C++11 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <deque>
#include <cassert>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <chrono>
#include <ctime>
#include <random>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#include <climits>
#include <horses.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007
ll worth[1005],X[1005],Y[1005];
bool over[1005];
int calc(){
for (int i=0;i<N;i++){
worth[i]=0;
over[i]=false;
}
for (int i=N-1;i>=0;i--){
if (over[i+1])
worth[i]=X[i]*worth[i+1];
else
worth[i]=X[i]*max(Y[i],worth[i+1]);
over[i]=(worth[i]>1000000000) | over[i+1];
if (over[i])
worth[i]%=MOD;
}
return worth[0];
}
int init(int N, int x[], int y[]){
for (int i=0;i<N;i++){
X[i]=x[i];
Y[i]=y[i];
}
return calc();
}
int updateX(int pos, int val){
X[pos]=val;
return calc();
}
int updateY(int pos, int val){
Y[pos]=val;
return calc();
}