QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#571162 | #9308. World Cup | sleet1 | WA | 0ms | 3684kb | C++14 | 850b | 2024-09-17 20:53:27 | 2024-09-17 20:53:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5+10 ;
//const int mol = ;
int a[N];
void solve(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin>>a[i];
}
a[n+1] = 0;
int ans = 0, flag = 1;
while(flag){
flag = 0;
for(int i = 1; i <= n; i++){
if(a[i] < a[i-1] && a[i] < a[i+1]){
a[i] = min(a[i-1], a[i+1]);
ans++;
}else if(a[i] < a[i-1]){
a[i] = a[i-1];
ans++;
}else if(a[i] < a[i+1]){
a[i] = a[i+1];
ans++;
}
// for(int j = 1; j <= n; j++){
// cout << a[j] << ' ';
// }
// cout << '\n';
if(i > 1 && a[i] != a[i-1]){
flag = 1;
}
}
}
cout << ans << '\n';
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int tt = 1;
cin>>tt;
for(int i = 1;i <= tt;i++){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3684kb
input:
1 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
output:
31
result:
wrong answer 1st numbers differ - expected: '1', found: '31'