이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |