UVa1260 - Sales

简介: UVa1260 - Sales
#include <cstdio>usingnamespacestd;
constintN=1010;
inta[N], b[N];
intn;
voidinput();
voidsolve();
intmain()
{
#ifndef ONLINE_JUDGEfreopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endifintt;
scanf("%d", &t);
while (t--) {
input();
solve();
    }
return0;
}
voidinput()
{
scanf("%d", &n);
for (inti=0; i<n; i++) {
scanf("%d", &a[i]);
    }
}
voidsolve()
{
for (inti=1; i<n; i++) {
intcnt=0;
for (intj=0; j<i; j++) {
if (a[j] <=a[i]) cnt++;
        }
b[i-1] =cnt;
    }
intans=0;
for (inti=0; i<n-1; i++) {
ans+=b[i];
    }
printf("%d\n", ans);
}
目录
相关文章
UVa11714 - Blind Sorting
UVa11714 - Blind Sorting
62 0
|
存储 供应链 C++
【PAT甲级 - C++题解】1079 Total Sales of Supply Chain
【PAT甲级 - C++题解】1079 Total Sales of Supply Chain
97 0
|
存储 机器学习/深度学习 算法
【PAT甲级】1087 All Roads Lead to Rome
【PAT甲级】1087 All Roads Lead to Rome
84 0
HDU-1057,A New Growth Industry(理解题意)
HDU-1057,A New Growth Industry(理解题意)
【1087】All Roads Lead to Rome (30 分)
【1087】All Roads Lead to Rome (30 分) 【1087】All Roads Lead to Rome (30 分)
126 0
1087. All Roads Lead to Rome (30)
#include #include #include #include using namespace std; int n, k; const int inf = 99999999; const int msize...
907 0

热门文章

最新文章