T1

老师的作业提示里说有难题,也有水题,果真很水。。。

单纯的模拟加暴力

 1 #include<iostream>
 2 using namespace std;
 3 int n;
 4 const int maxn=1e7+10;
 5 int cow[maxn];
 6 int ans=0;
 7 int cha(int i)
 8 {
 9     int res=0;
10     for(int j=i+1;j<=n;j++)
11     {
12         if(cow[i]>cow[j])
13         {
14             res++;
15             //cout<<111111<<endl;
16         }
17         
18         if(cow[i]<=cow[j])
19         {
20             break;
21         }
22     }
23     return res;
24 }
25 int main()
26 {
27     cin>>n;
28     for(int i=1;i<=n;i++)
29     {
30         cin>>cow[i];
31     }
32     /*for(int i=1;i<=n;i++)
33     {
34         cout<<cow[i]<<" ";
35     }*/
36     for(int i=1;i<=n;i++)
37     {
38         //cout<<cha(i)<<endl;
39          ans=ans+cha(i);
40     }
41     cout<<ans<<endl;
42     return 0;
43 }
原文地址:https://www.cnblogs.com/2529102757ab/p/10951720.html