Submission #830350

# Submission time Handle Problem Language Result Execution time Memory
830350 2023-08-19T04:15:30 Z mindiyak Horses (IOI15_horses) C++17
0 / 100
1500 ms 14228 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++){
		if(cur*x[i]*y[i]>y[MX_pos]){
			MX_pos = i;
			cur = x[i];
		}else{
			cur*=x[i];
		}
	}

	ll MX = 1;
	for(int i=0;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:34:17: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   34 |  int ans = multi(MX,y[MX_pos]);
      |            ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Execution timed out 1562 ms 14228 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -