NOIP2005 提高组第一题 谁拿了最多奖学金

来源:互联网 发布:压缩感知重构算法最新 编辑:程序博客网 时间:2024/04/28 16:44
谁拿了最多的奖学金
题目描述
  某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,获取的条件各自不同:
1)院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生均可获得; 

2)五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生均可获得; 

3)成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得; 

4)西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得; 

5)班级贡献奖,每人850元,班级评议成绩高于80分(>80)的学生干部均可获得; 

  只要符合条件就可以得奖,每项奖学金的获奖人数没有限制,每名学生也可以同时获得多项奖学金。例如姚林的期末平均成绩是87分,班级评议成绩82分,同时他还是一位学生干部,那么他可以同时获得五四奖学金和班级贡献奖,奖金总数是4850元。 

  现在给出若干学生的相关数据,请计算哪些同学获得的奖金总数最高(假设总有同学能满足获得奖学金的条件)。 

时间复杂度 O(n)

代码
   const
  maxn=100;
var
  a,g1,g2,g3:array[0..maxn] of longint;
  s:array[0..maxn] of string;
  c1,c2:array[0..maxn] of char;
  n,ans,i,max:longint;
  ch:char;


begin
  readln(n);
  for i:=1 to n do
    begin
      read(ch);
      s[i]:=s[i]+ch;
      while ch<>' ' do
        begin
          read(ch);
          s[i]:=s[i]+ch;
        end;
      readln(g1[i],g2[i],ch,c1[i],ch,c2[i],g3[i]);
    end;
  for i:=1 to n do
    begin
      if (g1[i]>80) and (g3[i]>0)
        then inc(a[i],8000);
      if (g1[i]>85) and (g2[i]>80)
        then inc(a[i],4000);
      if g1[i]>90 then inc(a[i],2000);
      if (g1[i]>85) and (c2[i]='Y')
        then inc(a[i],1000);
      if (g2[i]>80) and (c1[i]='Y')
        then inc(a[i],850);
    end;
  for i:=1 to n do
    begin
      if a[i]>max then
        begin
          max:=a[i];
          s[0]:=s[i];
        end;
      inc(ans,a[i]);
    end;
  writeln(s[0]);
  writeln(max);
  writeln(ans);
end.
0 0