제출 #283277

#제출 시각아이디문제언어결과실행 시간메모리
283277stoyan_malinin말 (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();
}

컴파일 시 표준 에러 (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...