제출 #869912

#제출 시각아이디문제언어결과실행 시간메모리
869912qin말 (IOI15_horses)C++17
34 / 100
1555 ms16000 KiB
#ifdef LOCAL
#else
#include "horses.h"
#endif
#include <bits/stdc++.h>
#define fi first
#define se second
#define ssize(x) int(x.size())
#define pn printf("\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double db;
int inf = 2e09; ll infll = 2e18; ll mod = 1e09+7;
vector<ll> X, Y; // UWAGA - GLOBALNIE ZADEKLAROWANE
int update(){
		int n = ssize(X);
		int opt = 0; ll mul = 1; bool overflow = 0; db tmp;
		for(int i = 1; i < n; ++i){
				mul *= X[i];
				if(mul >= mod) overflow = 1, mul %= mod;
				
				if(overflow) opt = i, mul = 1, overflow = 0;
				else{
						tmp = db(Y[opt])/db(Y[i]);
						if(db(mul) >= tmp) opt = i, mul = 1, overflow = 0;
				}
		}
		ll result = Y[opt];
		for(int i = 0; i <= opt; ++i) result = result * X[i] % mod;
		return int(result);
}
int updateX(int i, int val){ X[i] = val; return update(); }
int updateY(int i, int val){ Y[i] = val; return update(); }
int init(int n, int x[], int y[]){
		X.resize(n), Y.resize(n);
		for(int i = 0; i < n; ++i) X[i] = x[i], Y[i] = y[i];
		return update();
}
#ifdef LOCAL
int main(){
		int T = 1;
		for(++T; --T; ){
				int n = 3, x[3] = {2, 1, 3}, y[3] = {3, 2, 1};
				printf("%d\n", init(n, x, y));
		}
		return 0;
}
#endif
#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...