比赛 普及组2016模拟练习3 评测结果 AAAAAAAAAA
题目名称 中考分数 最终得分 100
用户昵称 __stdcall 运行时间 0.003 s
代码语言 C++ 内存使用 0.33 MiB
提交时间 2016-11-15 20:54:03
显示代码纯文本
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

struct man {
    int score,ranking,id;
    bool operator<( const man &rhs ) const {
        return score > rhs.score;
    }
}a[1010];

int n,m,x;

int main() {
    freopen( "mark.in", "r", stdin );
    freopen( "mark.out", "w", stdout );
    scanf( "%d%d", &n, &m );
    for( int i = 1; i <= n; ++i ) {
        scanf( "%d", &a[i].score );
        a[i].id = i;
    }
    scanf( "%d", &x );
    sort( a+1, a+n+1 );
    for( int i = 1; i <= n; ++i ) {
        if( i == 1 ) a[i].ranking = 1;
        else {
            if( a[i].score == a[i-1].score ) a[i].ranking = a[i-1].ranking;
            else a[i].ranking = i;
        }
        if( a[i].id == x ) {
            for( int k = 1; k <= m; ++k ) {
                if( a[i].ranking >= (k-1)*(n/m)+1 && a[i].ranking <= k*(n/m) ){
                    printf( "%d\n", k );
                    return 0;
                }
            }
        }
    }
    return 0;
}