제출 #764781

#제출 시각아이디문제언어결과실행 시간메모리
764781SanguineChameleon말 (IOI15_horses)C++17
34 / 100
1577 ms11960 KiB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

int mul(int a, int b) {
	if (a > mod / b) {
		return mod;
	}
	else {
		return a * b;
	}
}

const int maxN = 5e5 + 20;
int X[maxN];
int Y[maxN];
int N;

int calc() {
	int best = 1;
	int gain = 1;
	for (int i = 2; i <= N; i++) {
		gain = mul(gain, X[i]);
		if (mul(gain, Y[i]) > Y[best]) {
			best = i;
			gain = 1;
		}
	}
	int res = 1;
	for (int i = 1; i <= best; i++) {
		res = 1LL * res * X[i] % mod;
	}
	res = 1LL * res * Y[best] % mod;
	return res;
}

int init(int _N, int _X[], int _Y[]) {
	N = _N;
	for (int i = 1; i <= N; i++) {
		X[i] = _X[i - 1];
		Y[i] = _Y[i - 1];
	}
	return calc();
}

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

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

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'int calc()':
horses.cpp:33:26: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   33 |   res = 1LL * res * X[i] % mod;
      |         ~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:35:28: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   35 |  res = 1LL * res * Y[best] % mod;
      |        ~~~~~~~~~~~~~~~~~~~~^~~~~
#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...