QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#33155#1822. Mountainous Palindromic Subarraybulijiojiodibuliduo#WA 2ms3724kbC++1009b2022-05-29 01:55:502022-05-29 01:55:51

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-29 01:55:51]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3724kb
  • [2022-05-29 01:55:50]
  • 提交

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);
}

詳細信息

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'