#include <bits/stdc++.h>
#include "horses.h"
#define ll long long
using namespace std;
const ll MOD = 1e9 + 7, MAXN = 5e5 + 10;
set < int > s;
int X[MAXN], Y[MAXN], N;
int solve() {
vector < int > v;
for(int x : s) {
v.push_back(-x);
if(v.size() == 30) break;
}
reverse(v.begin(), v.end());
v.push_back(N);
for(int i : v) cout << i << ' '; cout << '\n';
ll product = 1, answer = 0;
for(int i = 0; i < (int) v.size() - 1; ++i) {
product *= X[v[i]];
ll maximum = 0;
for(int j = v[i]; j < v[i + 1]; ++j) {
maximum = max(maximum, (ll)Y[j]);
}
answer = max(answer, maximum * product);
}
if(!v.empty()) {
for(int i = 0; i < v[0]; ++i) {
answer *= X[i];
answer %= MOD;
}
}
return answer;
}
int updateX(int pos, int val) {
if(X[pos] > 1) s.erase(s.find(-pos));
X[pos] = val;
if(X[pos] > 1) s.insert(-pos);
return solve();
}
int updateY(int pos, int val) {
Y[pos] = val;
return solve();
}
int init(int _N, int _X[], int _Y[]) {
N = _N;
for(int i = 0; i < N; ++i) {
X[i] = _X[i];
Y[i] = _Y[i];
if(X[i] > 1) s.insert(-i);
}
return solve();
}
// int main() {
// int X[] = {2, 1, 3};
// int Y[] = {3, 4, 1};
// cout << init(3, X, Y) << '\n';
// cout << updateY(1, 2) << '\n';
// }
Compilation message
horses.cpp: In function 'int solve()':
horses.cpp:16:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
16 | for(int i : v) cout << i << ' '; cout << '\n';
| ^~~
horses.cpp:16:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
16 | for(int i : v) cout << i << ' '; cout << '\n';
| ^~~~
horses.cpp:32:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
32 | return answer;
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1570 ms |
34648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |