0
点赞
收藏
分享

微信扫一扫

ZCMU—1067


1607: 大二下之悬梁刺股


Time Limit: 1 Sec  Memory Limit: 128 MB

[​​Submit​​​][​​Status​​​][​​Web Board​​]

Description


这个时候应该在干嘛呢,没事无聊就去数数吧,给你N个数Ai,我有Q个询问,你告诉我,我问的每个位置的数在他前面比他大的数的个数。(n<10000,q<100000,Ai<10000)


Input


一个N

  接下来N个数

再一个Q

Q个数,表示数组里的第i个位置的数〈i的范围是[1,n]〉

-1结束输入


Output


输出第i个数前面比他大的数的个数


Sample Input


3


3 2 1


3


1 2 3


-1


Sample Output

0 1 2


【分析】


没什么坑的题目...之所以写这道题只是因为这是个系列....强迫症又犯了..


【代码】


#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
int n;
while (~scanf("%d",&n))
{
if (n==-1) return 0;
int a[20000];
int f[20000]={0};
for (int i=0;i<n;i++)
{
scanf("%d",&a[i]);
for (int j=0;j<i;j++) if (a[j]>a[i]) f[i]++;
}
int p;scanf("%d",&p);
for (int i=0;i<p;i++)
{
int x;scanf("%d",&x);
printf("%d\n",f[x-1]);
}
}
return 0;
}




2



HINT


2



HINT




Source





[ ​​Submit​​][​Status​​][​Web Board​​]



举报

相关推荐

1067 Problem A

ZCMU—A

ZCMU—1263

ZCMU—1374

ZCMU—1306

ZCMU—1798

ZCMU—1776

ZCMU—1676

0 条评论