QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#127819#1171. Integer Array ShuffleHanx16MsgrWA 1ms3876kbC++14411b2023-07-20 09:11:192023-07-20 09:11:21

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-20 09:11:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3876kb
  • [2023-07-20 09:11:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n, a[1000005];
signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	int ans = 0;
	for (int i = 1; i < n; ++i)
		if (a[i] > a[i - 1] && a[i] > a[i + 1])
			++ans;
	if (ans == 0) cout << 0 << '\n';
	else {
		if (a[n] > a[n - 1]) ++ans;
		cout << ceil(log2(ans)) + 1 << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2 2 5

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

6
1 5 8 10 3 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

8
14253630 18210471 431833031 681754868 791250850 811241570 837112104 858531105

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

3
2 2 5

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

7
4 2 4 2 5 3 4

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

8
92691902 57877007 167221695 197382747 709013587 643114183 962487887 112336349

output:

3

result:

ok 1 number(s): "3"

Test #7:

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

input:

8
14253630 811241570 18210471 431833031 858531105 837112104 681754868 791250850

output:

3

result:

ok 1 number(s): "3"

Test #8:

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

input:

8
1 1 1 1 1 1 1 1

output:

0

result:

ok 1 number(s): "0"

Test #9:

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

input:

8
858531105 837112104 811241570 791250850 681754868 431833031 18210471 14253630

output:

1

result:

ok 1 number(s): "1"

Test #10:

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

input:

8
1 2 2 2 2 1 1 1

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'