Submission #570228

# Submission time Handle Problem Language Result Execution time Memory
570228 2022-05-28T21:19:25 Z elpro123 Mountains (NOI20_mountains) C++14
64 / 100
2000 ms 2516 KB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){

long n;
cin>>n;
long heigh[n];

for(long i=0; i<n; i++){
    cin>>heigh[i];
}
long cont=0;
/*
for(long i=0; i<n-2; i++){
    for(long j=i+1; j<n-1; j++){
        for(long k=j+1; k<n; k++){
            cout<<heigh[i]<<" "<<heigh[j]<<" "<<heigh[k]<<"\n";
            if(heigh[i]<heigh[j] and heigh[k]<heigh[j]){
                cont++;
            }
        }
    }
}
*/

long aux1=0, aux2=0, total=0;

for(long i=1; i<n-1; i++){
    for(long j=i-1; j>=0; j--){
        if(heigh[j]<heigh[i]){
            aux1++;
        }
    }
    for(long k=i+1; k<n; k++){
        if(heigh[k]<heigh[i]){
            aux2++;
        }
    }
    total = total + (aux1*aux2);
    aux1=0;
    aux2=0;
}

cout<<total<<"\n";

    return 0;
}

Compilation message

Mountains.cpp: In function 'int main()':
Mountains.cpp:15:6: warning: unused variable 'cont' [-Wunused-variable]
   15 | long cont=0;
      |      ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 2089 ms 2516 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2090 ms 2516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2090 ms 2516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 329 ms 348 KB Output is correct
12 Correct 339 ms 352 KB Output is correct
13 Correct 325 ms 348 KB Output is correct
14 Correct 329 ms 348 KB Output is correct
15 Correct 326 ms 352 KB Output is correct
16 Correct 371 ms 348 KB Output is correct
17 Correct 314 ms 352 KB Output is correct
18 Correct 344 ms 344 KB Output is correct
19 Correct 295 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2090 ms 2516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 2089 ms 2516 KB Time limit exceeded
3 Halted 0 ms 0 KB -