1080.MOOC期末成績

3250 ワード

中国の大学MOOC(http://www.icourse163.org/)「データ構造」を学ぶ学生は、合格証明書を取得するには、まず200点以上のオンラインプログラミング作業点を取得し、総評価で60点以上(100点満点)を取得する必要があります.総合評価成績の計算式はG=(G期間中x 40%+G期末x 60%)であり、G期間中 > G期末そうでなければ、総評GはG期末です.ここG期中 とG期末 それぞれ学生の期中和期末成績である.
今の問題は、試験のたびに独立した成績表が出ることです.この問題はプログラムを書いて、異なる成績表を1枚にしてください.
入力形式:
1行目に入力すると、P(オンラインプログラミングの宿題をした学生数)、M(中間試験を受けた学生数)、N(期末試験を受けた学生数)の3つの整数が与えられます.各数は10000を超えません.
次は3つの入力があります.第1ブロックはP個のオンラインプログラミング成績Gプログラミングを含む.第2ブロックはM中間試験の成績G中間を含む.第3ブロックはN個の期末試験の成績G期末を含む.各成績は1行を占め、形式は:学生の学号の点数です.そのうち、学生の学号は20文字を超えない英語のアルファベットと数字である.点数は非負の整数(プログラミング総得点は最高900点、期間中和期末の最高得点は100点).
出力フォーマット:
合格証明書を取得した学生のリストを印刷します.各学生は1行を占め、フォーマットは次のとおりです.
学生番号Gプログラミング G期中 G期末 G
ある成績が存在しない場合(例えば、ある人が中間試験を受けていない場合)、対応する位置に「-1」を出力します.出力順序は、総評価点数(整数まで四捨五入)で減算されます.並列があれば、学号ごとに増加します.問題は学号が重複していないことを保証し、少なくとも1人の合格した学生が存在する.
サンプルを入力:
6 6 7
01234 880
a1903 199
ydjh2 200
wehu8 300
dx86w 220
missing 400
ydhfu77 99
wehu8 55
ydjh2 98
dx86w 88
a1903 86
01234 39
ydhfu77 88
a1903 66
01234 58
wehu8 84
ydjh2 82
missing 99
dx86w 81

出力サンプル:
missing 400 -1 99 99
ydjh2 200 98 82 88
dx86w 220 88 81 84
wehu8 300 55 84 84

===========================================================================
考え方:
少しカード時間があるので、構造体+mapを使えばいいです.ポイントは、一人の普段の成績が継続計算の基準に合っているかどうかを判断することです.
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

struct student
{
    string num;
    int hw;
    int mid;
    int fin;
    int sco;
    student()
    {
        mid = fin = sco = -1;
    }
}stu[10005];

bool cmp(student x, student y)
{
    if(x.sco == y.sco)
        return x.num < y.num;
    else
        return x.sco > y.sco;
}

int main()
{
    int p,m,n,i,cnt=0;
    int temp;
    string tt;
    map s;
    cin>>p>>m>>n;
    for(i=0;i

>tt>>temp; if(temp>=200 && temp<=900) { if(!s[tt]) { s[tt] = ++cnt; stu[cnt].num = tt; stu[s[tt]].hw = temp; } } } for(i=0;i>tt>>temp; if(s[tt] && temp>=0 && temp<=100) stu[s[tt]].mid = temp; } for(i=0;i>tt>>temp; if(s[tt] && temp>=0 && temp<=100) { stu[s[tt]].fin = temp; if(stu[s[tt]].mid <= stu[s[tt]].fin) stu[s[tt]].sco = stu[s[tt]].fin; else stu[s[tt]].sco = (int)(stu[s[tt]].mid*0.4 + stu[s[tt]].fin*0.6 + 0.5); } } sort(stu+1,stu+cnt+1,cmp); for(i=1;i<=cnt;i++) { if(stu[i].sco < 60) break; cout<