Submission #408904

#TimeUsernameProblemLanguageResultExecution timeMemory
408904dxz05Horses (IOI15_horses)C++14
34 / 100
86 ms14008 KiB
#include "horses.h"
#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;

using namespace std;

const int MAXN = 111111;
const int MOD = 1000000007;

int X[MAXN], Y[MAXN];
int N;

int calc(){
    ld best = 0, mult = 0;
    for (int i = 0; i < N; i++){
        mult += log2(X[i]);
        best = max(best, mult + log2(Y[i]));
    }

    ll ans = 1;

    mult = 0;
    for (int i = 0; i < N; i++){
        mult += log2(X[i]);
        ans = (ans * X[i]) % MOD;

        if (mult + log2(Y[i]) == best){
            ans = (ans * Y[i]) % MOD;
            return ans;
        }
    }

    return 0;
}

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 calc();
}

int updateX(int pos, int val) {
    X[pos] = val;
	return calc();
}

int updateY(int pos, int val) {
    Y[pos] = val;
	return calc();
}

Compilation message (stderr)

horses.cpp: In function 'int calc()':
horses.cpp:31:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   31 |             return ans;
      |                    ^~~
#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...