답안 #830369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830369 2023-08-19T04:43:38 Z mindiyak 말 (IOI15_horses) C++14
0 / 100
1500 ms 14232 KB
#include "horses.h"
#include <vector>
#include <iostream>
 
using namespace std;
typedef long long ll;
 
 
vector<ll> x;
vector<ll> y;
int n;
int M = 1e9+7;
 
ll multi(ll a,ll b){
	return ((a%M)*(b%M))%M;
}
 
int calc(){
	int MX_pos = 0;
	ll cur = x[0];

	for(int i=1;i<n;i++){
		ll multiply = cur*x[i];
		if(multiply*y[i]>y[MX_pos] || multiply > 1e9){
			MX_pos = i;
			cur=x[i];
		}else{
			cur*=x[i];
		}
	}

	ll MX = x[0]%M;
	for(int i=1;i<MX_pos+1;i++){
		MX = multi(MX,x[i]);
	}
	int ans = multi(MX,y[MX_pos]);
	return ans;
}
 
int init(int N, int X[], int Y[]) {
	n = N;
	for(int i=0;i<N;i++)x.push_back(X[i]);
	for(int i=0;i<N;i++)y.push_back(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();
}

Compilation message

horses.cpp: In function 'int calc()':
horses.cpp:24:33: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   24 |   if(multiply*y[i]>y[MX_pos] || multiply > 1e9){
      |                                 ^~~~~~~~
horses.cpp:36:17: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   36 |  int ans = multi(MX,y[MX_pos]);
      |            ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1557 ms 14232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -