Submission #68962

#TimeUsernameProblemLanguageResultExecution timeMemory
68962theknife2001Horses (IOI15_horses)C++17
17 / 100
1569 ms16296 KiB
#include "horses.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; const int N=5e5+55; long long x[N]; long long y[N]; long long s[N]; int n; int m=1e9+7; int solve() { int i=N-1; long long ret=0; long long temp=1; while(i--) { s[i]=x[i]*s[i+1]; if(s[i]>1e9) break; } if(i==-1) i=0; int bestpos=n-1; for(;i<n;i++) { temp*=x[i]; if(y[i]>s[i+1]&&y[i]*temp>ret) { ret=y[i]*temp; bestpos=i; } } ret=1; for(int i=0;i<=bestpos;i++) { ret*=x[i]; ret%=m; } ret*=y[bestpos]; return (ret%m); } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<N;i++) { s[i]=1; x[i]=X[i]; y[i]=Y[i]; } s[n]=1; 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 solve()':
horses.cpp:22:15: warning: conversion to 'double' from 'long long int' may alter its value [-Wconversion]
         if(s[i]>1e9)
            ~~~^
horses.cpp:38:13: warning: declaration of 'i' shadows a previous local [-Wshadow]
     for(int i=0;i<=bestpos;i++)
             ^
horses.cpp:16:6: note: shadowed declaration is here
  int i=N-1;
      ^
horses.cpp:44:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return (ret%m);
            ~~~~^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:47:33: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 int init(int N, int X[], int Y[])
                                 ^
horses.cpp:6:11: note: shadowed declaration is here
 const int N=5e5+55;
           ^
#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...