Submission #66014

#TimeUsernameProblemLanguageResultExecution timeMemory
66014daniel_02Horses (IOI15_horses)C++17
34 / 100
1586 ms8508 KiB
#include <iostream>
#include <horses.h>
#include <cmath>
#include <stdio.h>

#define ll long long

using namespace std;

const int MOD = 1e9 + 7;
const int sz = 5e5 + 7;

int n, x[sz], y[sz];

int init(int N, int X[], int Y[]) {

    double h = 0;
    ll cur = 1;
    double ans = 0;
    ll ans1 = 1;
    n = N;

    for (int i = 0; i < N; i++)
    {
        x[i] = X[i];
        y[i] = Y[i];

        h += log10(x[i]);
        cur = (cur * x[i]) % MOD;
        if (ans * 1.0 < h + log10(y[i]))
        {
            ans = log10(y[i]) + h;
            ans1 = (y[i] * 1LL * cur) % MOD;
        }
    }

    return (ans1 % MOD);
}

int updateX(int pos, int val) {
    x[pos] = val;
    return init(n, x, y);
}

int updateY(int pos, int val) {
    y[pos] = val;
    return init(n, x, y);
}

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:37:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return (ans1 % MOD);
            ~~~~~~^~~~~~
#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...