#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n;
int x[500005]={100,100,100,100,100,100,100,100,100,100,100,100,100,100,100};
int y[500005]={100,100,100,100,100,100,100,100,100,100,100,100,100,100,100};
int init(int N, int X[], int Y[]) {
for(int i=0;i<N;i++){
cout << X[i] << " ";
}
cout << "\n";
for(int i=0;i<N;i++){
cout << Y[i] << " ";
}
cout << "\n";
n=N;
for(ll i=0;i<N;i++){
x[i]=X[i];
y[i]=Y[i];
}
ll answer = 1,tmp=1,i=-1;
for(ll I=N-1;I>=0;I--){
if(tmp*X[I]>2000000000) {i=I;break;}
tmp *= X[I];
}
if(i==-1) i=0;
ll place = i;
ll Max=1,tmp2=1;
for(ll j=i;j<N;j++){
tmp2*=X[j];
tmp2*=Y[j];
if(tmp2>Max){
Max = tmp2;
place = j;
}
tmp2/=Y[j];
}
for(ll j=0;j<=place;j++){
answer*=X[j];
answer %= (1000000007);
}
answer*=Y[place];
answer %= 1000000007;
return answer;
}
int updateX(int pos, int val) {
x[pos]=val;
return init(n,x,y);
}
int updateY(int pos, int val) {
y[pos]=val;
return init(n,x,y);
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:45:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
45 | return answer;
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1529 ms |
61576 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |