Submission #283277

#TimeUsernameProblemLanguageResultExecution timeMemory
283277stoyan_malininHorses (IOI15_horses)C++14
34 / 100
109 ms13944 KiB
#include "horses.h" //#include "grader.cpp" #include <cmath> #include <vector> #include <iostream> using namespace std; const int MAXN = 1e5 + 5; const long long mod = 1e9 + 7; int n; int x[MAXN], y[MAXN]; long long evalBest() { double lnSum = 0; pair <double, int> opt = {-1, -1}; for(int i = 0;i<n;i++) { lnSum += log(x[i]); if(lnSum+log(y[i])>opt.first) { opt = {lnSum+log(y[i]), i}; } } long long product = 1; for(int i = 0;i<=opt.second;i++) product = (product*1LL*x[i])%mod; return (product*y[opt.second])%mod; } int init(int N, int X[], int Y[]) { n = N; for(int i = 0;i<n;i++) { x[i] = X[i]; y[i] = Y[i]; } return evalBest(); } int updateX(int pos, int val) { x[pos] = val; return evalBest(); } int updateY(int pos, int val) { y[pos] = val; return evalBest(); }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:45:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   45 |     return evalBest();
      |            ~~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:51:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   51 |  return evalBest();
      |         ~~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:57:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   57 |  return evalBest();
      |         ~~~~~~~~^~
#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...