Submission #921282

#TimeUsernameProblemLanguageResultExecution timeMemory
921282ByeWorldHorses (IOI15_horses)C++14
17 / 100
22 ms23328 KiB
#include "horses.h"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
const int MAXN = 2e5+10;
const int MOD = 1e9+7;
typedef pair<int,int> pii;
typedef pair<int,pii> ipii;

ll mul(ll x, ll y){
	ll num = (x*y)%MOD;
	return num;
}
int n;
ll pr[MAXN], ans[MAXN], x[MAXN], y[MAXN], mx;

int calc(){
	pr[0] = 1; mx = -1;
	for(int i=1; i<=n; i++){
		pr[i] = mul(pr[i-1], x[i]);
		ans[i] = mul(pr[i], y[i]);
		mx = max(mx, ans[i]);
	}
	if(mx >= MOD-8) assert(false);
	return mx;
}

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) {	
	x[pos+1] = val;
	return calc();
}

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

Compilation message (stderr)

horses.cpp: In function 'int calc()':
horses.cpp:32:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   32 |  return mx;
      |         ^~
#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...