Submission #1357137

#TimeUsernameProblemLanguageResultExecution timeMemory
1357137ezzzayHorses (IOI15_horses)C++20
17 / 100
21 ms14360 KiB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
vector<ll>x,y;
const ll mod=1e9+7;
int init(int N, int X[], int Y[]) {
    x.clear();
    y.clear();
    for(int i=0;i<N;i++)x.pb(X[i]);
    for(int i=0;i<N;i++)y.pb(Y[i]);
    ll p=x.back();
    int l=N-1;
    while(l-1>=0 and x[l-1]<=2e9/p ){
        p*=x[--l];
    }
    // suuliin l ees shalgaad avchinaa 
    ll P=1;
    for(int i=0;i<l;i++){
        P*=x[i];
        P%=mod;
    }
    
    p=1;
    ll mx=1;
    for(int i=l;i<N;i++){
        p*=x[i];
        mx=max(mx,p*y[i]);
    }
    P*=mx;
    P%=mod;
    return P;
    
}

int updateX(int pos, int val) {	
    return 0;
}

int updateY(int pos, int val) {
    int N=x.size();
    y[pos]=val;
    return 0;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...