题解

26 条题解

  • -1
    @ 2017-08-03 10:46:57
    #include <cstdio>
    #include <iostream>
    #include <algorithm>
    
    using namespace std;
    
    int n, m;
    
    struct person {
        int num;
        int score;
    } p[10000];
    
    bool cmp(person a, person b) {
        return (a.score > b.score);
    }
    
    bool cmp2(person a, person b) {
        if (a.score != b.score) return (a.score > b.score);
        else return (a.num < b.num);
    }
    
    int main() {
        cin >> n >> m;
        for (int i = 0; i < n; i++) {
            cin >> p[i].num >> p[i].score;
        }
        sort(p, p + n, cmp);
        int pos = 0;
        while (p[pos].score >= p[(int)(m * 1.5) - 1].score) {
            pos++;
        }
    
        cout << p[(int)(m * 1.5) - 1].score << " " << pos << endl;
        sort(p, p + pos, cmp2);
        for (int i = 0; i < pos; i++) {
            cout << p[i].num << " " << p[i].score << endl;
        }
        return 0;
    }
    
  • -1
    @ 2017-07-03 11:06:15

    两个空格。。。。。。。。

  • -1
    @ 2016-10-08 21:37:47
    #include<iostream>
    #include<algorithm> 
    using namespace std;
    struct per{
        int k;
        double s;
    }a[5001];
    bool cmp (per x, per y)
    {
        if(x.s < y.s)
            return false;
        else if(x.s == y.s && x.k > y.k)
            return false;
        return true;
    }
    int main()
    {
        int n, m;
        cin >> n >> m;
        for(int i = 1; i <= n; i++)
            cin >> a[i].k >> a[i].s;
        sort(a+1, a+n+1, cmp); 
        int t;
        t = m * 1.5;
        int b = a[t].s;
        cout << b << ' ';
        int c = 0;
        for(int i = 1; a[i].s >= b; i++)
            c++;
        cout << c << endl;
        for(int i = 1; i <= c; i++)
            cout << a[i].k << ' ' << a[i].s << endl;
        return 0;
    }
    
  • -1
    @ 2016-07-21 20:29:03

    type re=record
    xh,fs:longint;
    end;
    var
    m,n,i,j,k:longint;
    a:array[1..10000]of re;
    tmp:re;
    begin
    readln(n,m);
    for i:=1 to n do readln(a[i].xh,a[i].fs);
    for i:=1 to n-1 do
    for j:=1 to n-i do
    begin
    if a[j].xh>a[j+1].xh then
    begin
    tmp:=a[j];
    a[j]:=a[j+1];
    a[j+1]:=tmp;
    end;
    end;
    for i:=1 to n-1 do
    for j:=1 to n-i do
    begin
    if a[j].fs<a[j+1].fs then
    begin
    tmp:=a[j];
    a[j]:=a[j+1];
    a[j+1]:=tmp;
    end;
    end;
    m:=trunc(m*1.5);
    k:=a[m].fs;
    i:=1;
    while a[i].fs>=k do inc(i);
    dec(i);
    writeln(k,' ',i);
    for j:=1 to i do writeln(a[j].xh,' ',a[j].fs);
    end.
    这题其实两次排序就可以 先将学号排一遍 再把分数排一遍 不过第二次必须得用稳定排序 泡排就行归并没必要

  • -1
    @ 2016-07-08 08:15:29

    水题,不用快排,模拟+排序,很容易
    var
    n,m,i,j,t,bz:longint;
    a,b:array[1..5100] of longint;
    begin
    readln(n,m);
    for i:=1 to n do readln(a[i],b[i]);
    for i:=1 to n-1 do
    for j:=i+1 to n do
    if (b[i]<b[j]) or ((b[i]=b[j])and(a[i]>a[j])) then begin
    t:=a[i];a[i]:=a[j];a[j]:=t;
    t:=b[i];b[i]:=b[j];b[j]:=t;
    end;
    m:=trunc(m*1.5);
    bz:=b[m];
    while (m<=n)and(b[m]>=bz) do inc(m);
    if b[m]<bz then dec(m);
    writeln(bz,' ',m);
    for i:=1 to m do writeln(a[i],' ',b[i]);
    end.

  • -1
    @ 2016-05-21 17:03:31

    题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题
    题题题题题题题题题题题题题题题题题题题题题题题题题题题题水水水水题题题题题
    题题题题题题题题题题题题题题题题题题题题题题题题水水水水水水水水水题题题题
    题题题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题
    题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题题题
    题题题题题题题题题题题水水水水题水水水水水水水水水水水题题题题题题题题题题
    题题题题题题题题水水水水水水水题水水水题题水水水水水题题题题题题题题题题题
    题题题水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
    题水水水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
    题水水水水水水水水水水水水题题题题题题题水水水水水水水水水水水题题题题题题
    题水水水水水水水水水水水水题题题题题题水水水水水水水水水水水水水水题题题题
    题题水水水水水水水水水水题题题题题水水水水水水题题题水水水水水水水题题题题
    题题题题题题题题水水水水题题题题题水水水水题题题题题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水题题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
    题题题题题题题题水水水水题题题题水水水题题水水水水题题水水水水水题题题题题
    题题水水题题题水水水水水题题题题水水水题题水水水题题题水水水水水题题题题题
    题题水水水水水水水水水水题题题题题水水题题水水题题题题水水水水水题题题题题
    题题题水水水水水水水水水题题题题题题题题水水水题题题题水水水水题题题题题题
    题题题题题水水水水水水水题题题题题题题题水水水题水水水水题题题题题题题题题
    题题题题题题水水水水水水题题题题题题题水水水水题题水水水水题题题题题题题题
    题题题题题题题题题水水水题题题题题题水水水水水题题题水水水水水水水题题题题
    题题题题题题题题题题题题题题题题水水水水水水题题题题题水水水水水水题题题题
    题题题题题题题题题题题题题题题水水水水水水题题题题题题水水水水水水水题题题
    题题题题题题题题题题题题题题水水水水水题题题题题题题题题水水水水水水题题题
    题题题题题题题题题题题题题水水水水水题题题题题题题题题题题水水水水题题题题
    题题题题题题题题题题题题水水水题题题题题题题题题题题题题题题水水水题题题题
    题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题

信息

ID
1813
难度
4
分类
(无)
标签
递交数
1558
已通过
692
通过率
44%
被复制
17
上传者