This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll md = 1000000007;
vector<pair<ll,ll> > x;
vector<pair<ll,ll> > y;
ll n;
pair<ll,ll> mult(pair<ll,ll> a, pair<ll,ll> b){
ll mod = a.first*b.first*md+a.second*b.first+a.first*b.second;
ll i = a.second*b.second;
mod+=(i/md);
i=i%md;
return make_pair(mod,i);
}
int query(){
pair<ll,ll> mx = make_pair(0,1);
pair<ll,ll> current = make_pair(0,1);
for (ll i = 0; i<n; i++){
current=mult(current,x[i]);
auto ans = mult(current,y[i]);
if (ans>mx){
mx=ans;
}
}
return mx.second;
}
int init(int N, int X[], int Y[]) {
n=N;
x.resize(n);
y.resize(n);
for (ll i = 0; i<n; i++){
x[i]=make_pair(0,X[i]);
y[i]=make_pair(0,Y[i]);
}
return query();
}
int updateX(int pos, int val) {
x[pos]=make_pair(0,val);
return query();
}
int updateY(int pos, int val) {
y[pos]=make_pair(0,val);
return query();
}
Compilation message (stderr)
horses.cpp: In function 'int query()':
horses.cpp:28:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return mx.second;
~~~^~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |