Submission #876048

#TimeUsernameProblemLanguageResultExecution timeMemory
876048Elvin_FritlHorses (IOI15_horses)C++17
0 / 100
16 ms18012 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 545 , inf = 1e9 + 199 , mod = 1e9 + 7; #include "horses.h" ll n , x[N] , y[N]; long double xlog[N] , ylog[N]; int calc(){ ll curr = 1 , mx = 0 , ind=0; for(int i=0;i<n;i++){ curr += xlog[i]; if(mx < curr + ylog[i]){ mx = curr + ylog[i]; ind = i; } } ll res=1; for(int i=0;i<=ind;i++){ res *= x[i]; res %= mod; } return (res*y[ind])%mod; } int init(int N,int X[],int Y[]){ n=N; for(int i=0;i<n;i++){ x[i]=X[i]; xlog[i] = log(x[i]); y[i]=Y[i]; ylog[i] = log(y[i]); } return calc(); } int updateX(int pos,int val){ x[pos]=val; xlog[pos] = log(x[pos]); return calc(); } int updateY(int pos,int val){ y[pos]=val; ylog[pos] = log(y[pos]); return calc(); }

Compilation message (stderr)

horses.cpp: In function 'int calc()':
horses.cpp:16:14: warning: conversion from 'long double' to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
   16 |         curr += xlog[i];
      |         ~~~~~^~~~~~~~~~
horses.cpp:18:23: warning: conversion from 'long double' to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
   18 |             mx = curr + ylog[i];
      |                  ~~~~~^~~~~~~~~
horses.cpp:28:24: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   28 |     return (res*y[ind])%mod;
      |            ~~~~~~~~~~~~^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:31:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   31 | int init(int N,int X[],int Y[]){
      |          ~~~~^
horses.cpp:6:11: note: shadowed declaration is here
    6 | const int N = 1e5 + 545 , inf = 1e9 + 199 , mod = 1e9 + 7;
      |           ^
#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...