QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#33155 | #1822. Mountainous Palindromic Subarray | bulijiojiodibuliduo# | WA | 2ms | 3724kb | C++ | 1009b | 2022-05-29 01:55:50 | 2022-05-29 01:55:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N=1010000;
int n,a[N],ans;
int main() {
scanf("%d",&n);
rep(i,1,n+1) {
scanf("%d",&a[i]);
}
rep(i,2,n) if (a[i]>a[i-1]&&a[i]>a[i+1]) {
int l=i,r=i;
while (l-1>=1&&r+1<=n&&a[l-1]==a[r+1]) --l,++r;
ans=max(ans,r-l+1);
}
if (ans<=1) ans=-1;
printf("%d\n",ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3724kb
input:
8 2 1 2 3 2 1 7 8
output:
5
result:
ok answer is '5'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
5 2 5 8 7 2
output:
-1
result:
ok answer is '-1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3720kb
input:
1 19
output:
-1
result:
ok answer is '-1'
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 3720kb
input:
7 1 3 3 6 3 3 1
output:
7
result:
wrong answer expected '3', found '7'