Submission #795752

#TimeUsernameProblemLanguageResultExecution timeMemory
795752Username4132Horses (IOI15_horses)C++14
0 / 100
11 ms8404 KiB
#include "horses.h" #include<iostream> #include<cmath> using namespace std; using ll = long long; using ld = long double; #define forn(i, n) for(int i=0; i<(int)n; ++i) const int MAXN = 1010, MOD = 1000000007; int n, arr[MAXN], brr[MAXN]; ld pa[MAXN], pb[MAXN]; int calc(){ ll prod=1, res=-1; ld mx=0, sum=0; forn(i, n){ sum+=pa[i]; prod=(prod*arr[i])%MOD; if(mx<sum+pb[i]){ mx=sum+pb[i]; res=(prod*brr[i])%MOD; } } return res; } int init(int N, int X[], int Y[]) { n=N; forn(i, n){ arr[i]=X[i]; brr[i]=Y[i]; pa[i]=log((ld)X[i]); pb[i]=log((ld)Y[i]); } return calc(); } int updateX(int pos, int val) { arr[pos]=val; pa[pos]=log(val); return calc(); } int updateY(int pos, int val) { brr[pos]=val; pb[pos]=log(val); return calc(); }

Compilation message (stderr)

horses.cpp: In function 'int calc()':
horses.cpp:24:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   24 |  return res;
      |         ^~~
#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...