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 <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 (stderr)
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;
| ^~~~~~
# | 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... |