QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#123697#1822. Mountainous Palindromic SubarrayScarlett_boyWA 1ms3480kbC++23864b2023-07-13 12:32:282023-07-13 12:32:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-13 12:32:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3480kb
  • [2023-07-13 12:32:28]
  • 提交

answer

#include<bits/stdc++.h>

typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
int n;

void solve() {
    cin >> n;
    vector<int> a(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 1; i <= n;) {
        int j = i;
        while (j + 1 <= n && a[j + 1] > a[j]) {
            j++;
        }
        int z = 1;
        int len = 1;
        while (j + z <= n && j - z >= 1 && a[j + z] == a[j - z]) {
            z++;
            len += 2;
        }
        ans = max(ans, len);
        i = j + max(1, z - 1);
    }
    if (ans == 1)cout << -1;
    else cout << ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int _ = 1;
//    cin >> _;
    for (int o = 1; o <= _; o++) solve();

    return 0;
}
/*

1
4
4 5 7 9

*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3384kb

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: 3448kb

input:

5
2
5
8
7
2

output:

-1

result:

ok answer is '-1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3432kb

input:

1
19

output:

-1

result:

ok answer is '-1'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3480kb

input:

7
1
3
3
6
3
3
1

output:

7

result:

wrong answer expected '3', found '7'