update
This commit is contained in:
parent
0db4cafb56
commit
1a9419d0b8
@ -3,45 +3,30 @@
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
||||
using ll=int64_t;
|
||||
using ll = int64_t;
|
||||
using std::cin, std::cout;
|
||||
|
||||
const ll maxn=1e5+5;
|
||||
ll t, n, a[maxn], inf=(1l<<(sizeof(inf)*8-5)), ninf=-inf;
|
||||
const ll maxn = 1e5+5;
|
||||
ll t, n, a[maxn], ans, inf=(1l<<(sizeof(inf)*8-4));
|
||||
|
||||
int main(){
|
||||
std::iostream::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
|
||||
|
||||
cin>>t;
|
||||
while(t--){
|
||||
std::multiset<ll> rset, lset;
|
||||
ans = -inf;
|
||||
cin>>n;
|
||||
std::multiset<ll> lset, rset;
|
||||
for(ll i{1};i<=n;i++){
|
||||
cin>>a[i];
|
||||
rset.emplace(a[i]);
|
||||
}
|
||||
rset.erase(rset.find(a[1]));
|
||||
lset.emplace(a[1]);
|
||||
ll ans{ninf};
|
||||
for(ll j{2};j<n;j++){
|
||||
rset.erase(rset.find(a[j]));
|
||||
auto lit {lset.lower_bound(a[j])};
|
||||
decltype(rset.end()) rit;
|
||||
if(lit==lset.end())lit--;
|
||||
while(*lit>=a[j]){
|
||||
if(lit==lset.begin())goto end;
|
||||
--lit;
|
||||
}
|
||||
if(lit==lset.end() || (*lit)>=a[j])goto end;
|
||||
rit = rset.end();
|
||||
--rit;
|
||||
if(*rit<=a[j])goto end;
|
||||
ans=std::max(ans, (*lit) * a[j] * (*rit));
|
||||
for(ll i{2};i<n;i++){
|
||||
|
||||
end:;
|
||||
lset.emplace(a[j]);
|
||||
lset.emplace(a[i]);
|
||||
}
|
||||
cout<<(ans==ninf?-1:ans)<<'\n';
|
||||
// cout<<ans<<'\n';
|
||||
cout<<(ans==-inf?-1:ans)<<'\n';
|
||||
}
|
||||
}
|
18
src/20241118/T541155_in.cpp
Normal file
18
src/20241118/T541155_in.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
|
||||
using ll = int64_t;
|
||||
using std::cin, std::cout;
|
||||
|
||||
const ll inf = (1l<<32);
|
||||
|
||||
int main(){
|
||||
std::random_device rd;
|
||||
std::mt19937_64 mt{rd()};
|
||||
std::uniform_int_distribution<ll> uid{-inf, inf};
|
||||
ll t {100};
|
||||
while (t--) {
|
||||
cout<<uid(mt)<<'\n';
|
||||
}
|
||||
}
|
28
src/20241118/T541155_pai.cpp
Normal file
28
src/20241118/T541155_pai.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
using ll = int64_t;
|
||||
using std::cin, std::cout;
|
||||
|
||||
const ll maxn = 1e5+5;
|
||||
ll t, n, a[maxn], ans, inf=(1l<<(sizeof(inf)*8-4));
|
||||
|
||||
int main(){
|
||||
std::iostream::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
|
||||
|
||||
cin>>t;
|
||||
while(t--){
|
||||
ans = -inf;
|
||||
cin>>n;
|
||||
for(ll i{1};i<=n;i++)cin>>a[i];
|
||||
for(ll i{1};i<n-1;i++)
|
||||
for(ll j{i+1};j<n;j++)
|
||||
for(ll k{j+1};k<=n;k++){
|
||||
if(a[i]<a[j] && a[j]<a[k]){
|
||||
ans=std::max(ans, a[i]*a[j]*a[k]);
|
||||
}
|
||||
}
|
||||
cout<<(ans==-inf?-1:ans)<<'\n';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user