Submission #1189600

#TimeUsernameProblemLanguageResultExecution timeMemory
1189600pensiveHorses (IOI15_horses)C++20
34 / 100
1594 ms15944 KiB
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
#define REP(a,i,n) for (ll i=a;i<n;i++)
#define ll long long
#define ssize 500'005

const ll MOD = 1e9+7;
int N;
ll X[ssize], Y[ssize], rProd[ssize];

ll solve() {
    ll mx=0, hNum=1, ind=N-1;
    long double emx = -1, hiNum=0, ylog;
    REP(0,i,N) {
        hiNum += log10(X[i]);
        rProd[i+1] = (rProd[i]*X[i])%MOD;
        ylog = log10(Y[i]);
        if (hiNum+ylog > emx) {
            emx = hiNum+ylog;
            ind = i;
        }
    }
    return (rProd[ind+1]*Y[ind])%MOD;
}

ll init(int n, int x[], int y[]) {
    rProd[0]=1;
    N = n;
    REP(0,i,n) {
        X[i] = x[i];
        Y[i] = y[i];
    }
    return solve();
}

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

ll updateY(int pos, int val) {
    Y[pos] = val;
    return solve();
}
#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...