Submission #570243

# Submission time Handle Problem Language Result Execution time Memory
570243 2022-05-28T21:48:27 Z XJP12 Mountains (NOI20_mountains) C++14
79 / 100
2000 ms 2764 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin>>n;
  vector<ll> v(n);
  bool ban=true;
  bool ban2=true;
  ll one=0;
  ll zero=0;
  vector<ll> h(100,0);
  vector<ll> htwo(100,0);
  for(ll i=0; i<n; i++){
     cin>>v[i];
     if(v[i]==1){
        one++;
     }
     if(v[i]==0){
        zero++;
     }
     if(i>0 && ban==true){
        if(v[i]<v[i-1]) ban=false;
     }
     if(v[i]>100){
        ban2=false;
     }else{
        h[v[i]]++;
     }
  }
  if(ban==true){
     cout<<"0"<<endl;
     return 0;
  }
  if(one+zero==n){
   //  cout<<"hello"<<endl;
     ll zerotwo=0;
     ll ans=0;
     for(int i=0; i<n; i++){
        if(v[i]==0){
           zerotwo++;
           continue;
        }else{
           ans+=zerotwo*(zero-zerotwo);
        }
     }
     cout<<ans<<endl;
     return 0;
  }
  if(ban2==true){
     ll totall;
     ll totalr;
     ll ans=0;
     for(ll i=0; i<n; i++){
        totall=0;
        totalr=0;
        htwo[v[i]]++;
       // cout<<"numero actual "<<v[i]<<endl;
        for(ll j=0; j<v[i]; j++){
           totall+=htwo[j];
           totalr+=(h[j]-htwo[j]);
       //    cout<<totall<<totalr<<endl;
        }
        ans+=(totall*totalr);
     }
     cout<<ans<<endl;
     return 0;
  }
  ll cont=1;
  ll ans=0;
  ll a,b;
  while(cont<n-1){
     a=0;
     b=0;
     for(ll i=0; i<cont; i++){
        if(v[i]<v[cont]) a++;
     }
     for(ll i=cont+1; i<n; i++){
        if(v[i]<v[cont]) b++;
     }
     ans+=a*b;
     cont++;
  }
  cout<<ans<<endl;
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 197 ms 2644 KB Output is correct
3 Correct 219 ms 2644 KB Output is correct
4 Correct 198 ms 2644 KB Output is correct
5 Correct 194 ms 2644 KB Output is correct
6 Correct 184 ms 2644 KB Output is correct
7 Correct 184 ms 2644 KB Output is correct
8 Correct 208 ms 2644 KB Output is correct
9 Correct 187 ms 2644 KB Output is correct
10 Correct 222 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2644 KB Output is correct
2 Correct 45 ms 2644 KB Output is correct
3 Correct 49 ms 2644 KB Output is correct
4 Correct 44 ms 2644 KB Output is correct
5 Correct 46 ms 2644 KB Output is correct
6 Correct 58 ms 2644 KB Output is correct
7 Correct 49 ms 2644 KB Output is correct
8 Correct 39 ms 2644 KB Output is correct
9 Correct 39 ms 2644 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2644 KB Output is correct
2 Correct 45 ms 2644 KB Output is correct
3 Correct 49 ms 2644 KB Output is correct
4 Correct 44 ms 2644 KB Output is correct
5 Correct 46 ms 2644 KB Output is correct
6 Correct 58 ms 2644 KB Output is correct
7 Correct 49 ms 2644 KB Output is correct
8 Correct 39 ms 2644 KB Output is correct
9 Correct 39 ms 2644 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 61 ms 2644 KB Output is correct
12 Correct 67 ms 2644 KB Output is correct
13 Correct 73 ms 2644 KB Output is correct
14 Correct 60 ms 2644 KB Output is correct
15 Correct 61 ms 2644 KB Output is correct
16 Correct 61 ms 2644 KB Output is correct
17 Correct 70 ms 2656 KB Output is correct
18 Correct 50 ms 2644 KB Output is correct
19 Correct 63 ms 2644 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 83 ms 356 KB Output is correct
12 Correct 77 ms 352 KB Output is correct
13 Correct 83 ms 356 KB Output is correct
14 Correct 78 ms 356 KB Output is correct
15 Correct 89 ms 368 KB Output is correct
16 Correct 76 ms 340 KB Output is correct
17 Correct 73 ms 340 KB Output is correct
18 Correct 74 ms 340 KB Output is correct
19 Correct 69 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2644 KB Output is correct
2 Correct 45 ms 2644 KB Output is correct
3 Correct 49 ms 2644 KB Output is correct
4 Correct 44 ms 2644 KB Output is correct
5 Correct 46 ms 2644 KB Output is correct
6 Correct 58 ms 2644 KB Output is correct
7 Correct 49 ms 2644 KB Output is correct
8 Correct 39 ms 2644 KB Output is correct
9 Correct 39 ms 2644 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 61 ms 2644 KB Output is correct
12 Correct 67 ms 2644 KB Output is correct
13 Correct 73 ms 2644 KB Output is correct
14 Correct 60 ms 2644 KB Output is correct
15 Correct 61 ms 2644 KB Output is correct
16 Correct 61 ms 2644 KB Output is correct
17 Correct 70 ms 2656 KB Output is correct
18 Correct 50 ms 2644 KB Output is correct
19 Correct 63 ms 2644 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Execution timed out 2069 ms 2644 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 197 ms 2644 KB Output is correct
3 Correct 219 ms 2644 KB Output is correct
4 Correct 198 ms 2644 KB Output is correct
5 Correct 194 ms 2644 KB Output is correct
6 Correct 184 ms 2644 KB Output is correct
7 Correct 184 ms 2644 KB Output is correct
8 Correct 208 ms 2644 KB Output is correct
9 Correct 187 ms 2644 KB Output is correct
10 Correct 222 ms 2764 KB Output is correct
11 Correct 52 ms 2644 KB Output is correct
12 Correct 45 ms 2644 KB Output is correct
13 Correct 49 ms 2644 KB Output is correct
14 Correct 44 ms 2644 KB Output is correct
15 Correct 46 ms 2644 KB Output is correct
16 Correct 58 ms 2644 KB Output is correct
17 Correct 49 ms 2644 KB Output is correct
18 Correct 39 ms 2644 KB Output is correct
19 Correct 39 ms 2644 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 61 ms 2644 KB Output is correct
22 Correct 67 ms 2644 KB Output is correct
23 Correct 73 ms 2644 KB Output is correct
24 Correct 60 ms 2644 KB Output is correct
25 Correct 61 ms 2644 KB Output is correct
26 Correct 61 ms 2644 KB Output is correct
27 Correct 70 ms 2656 KB Output is correct
28 Correct 50 ms 2644 KB Output is correct
29 Correct 63 ms 2644 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 83 ms 356 KB Output is correct
42 Correct 77 ms 352 KB Output is correct
43 Correct 83 ms 356 KB Output is correct
44 Correct 78 ms 356 KB Output is correct
45 Correct 89 ms 368 KB Output is correct
46 Correct 76 ms 340 KB Output is correct
47 Correct 73 ms 340 KB Output is correct
48 Correct 74 ms 340 KB Output is correct
49 Correct 69 ms 340 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Execution timed out 2069 ms 2644 KB Time limit exceeded
52 Halted 0 ms 0 KB -