比赛 |
20151019 |
评测结果 |
WWTTTTTTEE |
题目名称 |
学数数 |
最终得分 |
0 |
用户昵称 |
pangxinying |
运行时间 |
6.186 s |
代码语言 |
C++ |
内存使用 |
4.51 MiB |
提交时间 |
2015-10-19 21:14:15 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;
const int maxn=100000+10;
const int maxm=1000000+10;
int n,q;
int a[maxn],b[maxm];
char s;
int x;
int sum;
int main()
{
freopen("jxthree.in","r",stdin);
freopen("jxthree.out","w",stdout);
cin>>n>>q;
for (int i=1; i<=n; i++)
{
cin>>a[i];
b[a[i]]++;
}
for (int k=2; k<=n; k++)
{
for (int i=1; i<=n-k+1; i++)
{
int max1=a[i];
for (int j=i+1; j<=i+k-1; j++)
{
if (a[j]>max1)
max1=a[j];
}
b[max1]++;
}
}
for (int i=1; i<=q; i++)
{
cin>>s>>x;
sum=0;
if (s=='>')
{
for (int i=x+1; i<=n; i++)
{
sum+=b[i];
}
cout<<sum<<endl;
}
else if (s=='=')
{
sum=b[x];
cout<<sum<<endl;
}
else
{
for (int i=1; i<x; i++)
{
sum+=b[i];
}
cout<<sum<<endl;
}
}
return 0;
}