Submission #418580

#TimeUsernameProblemLanguageResultExecution timeMemory
418580ChaskaHorses (IOI15_horses)C++11
17 / 100
1581 ms8116 KiB
#include "horses.h"
#include <bits/stdc++.h>
#define fo(a,b,c) for (int a=b;a<=c;a++)
using namespace std;
const int MAXN = 5e5+5,mod = 1e9+7;
typedef long long ll;
int n,x[MAXN],y[MAXN];
int sol()
{
	ll k = 0;
	ll res = -1;
	ll q=1;
	fo(i,max(0,n-1-35),n-1) {
		q *= x[i];
		if (k<=q) {
			res = i;
			k = y[i];
			q = 1;
		} else {
			q *= y[i];
			if (k<=q) {
				res = i;
				k = y[i];
				q = 1;
			} else {
				q /= y[i];
			}
		}
	}
	ll r = 1;
	fo(i,0,res) {
		r *= x[i];
		r %= mod;
	}
	r *= y[res];
	r %= mod;
	return r;
}
int init(int N, int X[], int Y[]) {
	n = N;
	fo(i,0,n-1) x[i] = X[i];
	fo(i,0,n-1) y[i] = Y[i];
	return sol();
}

int updateX(int pos, int val) {	
	x[pos] = val;
	return sol();
}

int updateY(int pos, int val) {
	y[pos] = val;
	return sol();
}

Compilation message (stderr)

horses.cpp: In function 'int sol()':
horses.cpp:37:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   37 |  return r;
      |         ^
#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...