# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
135306 | Boxworld | Horses (IOI15_horses) | C++14 | 1576 ms | 8568 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 "horses.h"
#include <bits/stdc++.h>
using namespace std;
const int bigint=1e9+7;
struct year{int x,y;}a[500100];
long long ans=0,s=0;
int n;
void dfs(int i,int h){
int H=h*a[i].x;
for (int j=0;j<=H;j++){
s+=a[i].y*j;
if (s>ans)ans=s;
if (i<n-1)dfs(i+1,H-j);
s-=a[i].y*j;
}
}
int init(int N, int X[], int Y[]){
n=N;
for (int i=0;i<N;i++){
a[i].x=X[i];
a[i].y=Y[i];
}
ans=0;
dfs(0,1);
return ans%bigint;
}
int updateX(int pos, int val) {
a[pos].x=val;
ans=0;
dfs(0,1);
return ans%bigint;
}
int updateY(int pos, int val) {
a[pos].y=val;
ans=0;
dfs(0,1);
return ans%bigint;
}
Compilation message (stderr)
# | 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... |