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
int N;
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[]){
N=n;
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();
}
Compilation message (stderr)
horses.cpp: In function 'int calc()':
horses.cpp:50:17: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
return worth[0];
~~~~~~~^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |