【u221】分数
2024-10-08 03:12:21
Time Limit: 1 second
Memory Limit: 128 MB
【问题描述】
高考分数刚刚公布。共有n人参加考试,为了便于填报志愿,教育部把所有考生的成绩平均分为m档。保证n是m的倍数。考试成绩名次在(k-1)(n/m)+1名到k(n/m)名的考生被分在第k档(k=1,2,3…m)。并列第i名的所有考生都算第i名。小Y刚参加完高考.迫切想知道自己被分在第几档,你能帮助他吗?
【输入格式】
第一行两个整数n,m≤1000,保证。是m的倍数。 接下来n行,每行一个整数Ai,表示第i个考生的成绩。 最后一行,一个整数x,l≤x≤n,表示询问第i个考生被分在哪一档。
【输出格式】
一行一个数,表示它被分在哪一档。
【数据规模】
Sample Input1
3 3
632
651
624
3
Sample Output1
3
【题目链接】:http://noi.qz5z.com/viewtask.asp?id=u221
【题解】
1 2 2 3 3 3 4
如果成绩为3则为第4名;如果成绩为4就是第7名了(而不是第5);
这样处理就可以了;模拟题;
【完整代码】
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <stack>
#include <string>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
void rel(LL &r)
{
r = 0;
char t = getchar();
while (!isdigit(t) && t!='-') t = getchar();
LL sign = 1;
if (t == '-')sign = -1;
while (!isdigit(t)) t = getchar();
while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
r = r*sign;
}
void rei(int &r)
{
r = 0;
char t = getchar();
while (!isdigit(t)&&t!='-') t = getchar();
int sign = 1;
if (t == '-')sign = -1;
while (!isdigit(t)) t = getchar();
while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
r = r*sign;
}
const int MAXN = 1e3+100;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
struct abc
{
int x,pos;
};
abc a[MAXN];
int n,m;
bool cmp(abc a,abc b)
{
return a.x > b.x;
}
int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(n);rei(m);
rep1(i,1,n)
rei(a[i].x),a[i].pos=i;
sort(a+1,a+1+n,cmp);
int x;
rei(x);
rep1(i,1,n)
if (a[i].pos==x)
{
int j = i-1;
while (j>=1 && a[j].x==a[i].x) j--;
j = j+1;
int t = n/m;
int k = m;
while ((k-1)*t>j) k--;
printf("%d\n",k);
break;
}
return 0;
}
最新文章
- python下print结果到文件中的方法
- njoj 1251 zlly长了一张包子脸
- 资源 之 4.4 Resource通配符路径 ——跟我学spring3
- 配置IIS服务器,APK文件下载
- wcf的连接数
- Stack的三种含义(数据超过栈的大小,就发生stack overflow)
- DBNull
- NM_CUSTOMDRAW 消息
- HTML5中将video设置为背景的方法
- 【easy】189. Rotate Array
- 原生js阻止表单跳转
- MySQL Point in Time Recovery the Right Way
- IDEA项目搭建十二——站点用户登录会话实现
- 【Python】pydot安装失败解决方法
- Java后台面试 常见问题
- Codeforces Round #256 (Div. 2) E Divisors
- Enable CSS active pseudo styles in Mobile Safari
- Mysql之explain调优
- brew || yarn 软件包管理工具
- excel解析的几种实现方法
热门文章
- 【水滴石穿】mobx-todos
- bnd workspace属性文件
- 【JZOJ4744】【NOIP2016提高A组模拟9.2】同余
- day39-Spring 13-Spring的JDBC模板:默认连接池的配置
- 免费报名 | 汇聚HBase&;大数据最前沿 Apache HBaseConAsia2019盛会火热来袭
- 数组map用法总结
- BZOJ 1008 越狱题解
- @codeforces - 1209H@ Moving Walkways
- idea 启动一直一直build以及勉勉强强的解决方案
- Lambda plus: 云上大数据解决方案