Submission #512522

#TimeUsernameProblemLanguageResultExecution timeMemory
512522AdamGSHorses (IOI15_horses)C++17
17 / 100
1575 ms12040 KiB
#include "horses.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=5e5+7; const ll MOD=1e9+7; ll X[LIM], Y[LIM], n; ll solve() { ll p=1, k=n; while(p<2*MOD && k>0) { --k; p*=X[k]; } if(p>=2*MOD) ++k; p=1; ll ans=0, x=1; rep(i, k) x=(x*X[i])%MOD; while(k<n) { p*=X[k]; ans=max(ans, p*Y[k]); ++k; } ans%=MOD; ans=(ans*x)%MOD; return ans; } int init(int D, int A[], int B[]) { n=D; rep(i, n) { X[i]=A[i]; Y[i]=B[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(); }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:39:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   39 |  return solve();
      |         ~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:44:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   44 |  return solve();
      |         ~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:49:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   49 |  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...