求教大神 vijos p1001 为什么过不了
pascal吧
全部回复
仅看楼主
level 10
程序:
type
shuju=record
name:string;
pingjun:integer;
pingyi:integer;
ganbu:char;
xibu:char;
lunwen:integer;
sum:longint;
end;
var
a:array[1..100] of shuju;
i,j,t,n,ans:integer;
s:string;
begin
readln(n);
for i:=1 to n do
begin
readln(s);
t:=1;
for j:=1 to length(s) do
begin
if t=6 then begin
if s[j]<>' ' then a[i].lunwen:=ord(s[j])-48;
if s[j]=' ' then inc(t);
end;
if t=5 then begin
if s[j]<>' ' then a[i].xibu:=s[j];
if s[j]=' ' then inc(t);
end;
if t=4 then begin
if s[j]<>' ' then a[i].ganbu:=s[j];
if s[j]=' ' then inc(t);
end;
if t=3 then begin
if s[j]<>' ' then a[i].pingyi:=a[i].pingyi*10+ord(s[j])-48;
if s[j]=' ' then inc(t);
end;
if t=2 then begin
if s[j]<>' ' then a[i].pingjun:=a[i].pingjun*10+ord(s[j])-48;
if s[j]=' ' then inc(t);
end;
if t=1 then begin
if s[j]<>' ' then a[i].name:=a[i].name+s[j];
if s[j]=' ' then inc(t);
end;
end;
end;
t:=1;
ans:=0;
for i:=1 to n do
begin
if (a[i].pingjun>80) and (a[i].lunwen>=1) then inc(a[i].sum,8000);
if (a[i].pingjun>85) and (a[i].pingyi>80) then inc(a[i].sum,4000);
if a[i].pingjun>90 then inc(a[i].sum,2000);
if (a[i].pingjun>85) and (a[i].xibu='Y') then inc(a[i].sum,1000);
if (a[i].pingyi>80) and (a[i].ganbu='Y') then inc(a[i].sum,850);
end;
ans:=0;
t:=1;
for i:=1 to n do
if a[t].sum<a[i].sum then t:=i;
writeln(a[t].name);
writeln(a[t].sum);
for i:=1 to n do
ans:=ans+a[i].sum;
write(ans);
end.
2014年06月20日 04点06分 1
level 10
输入没问题呀
2014年06月20日 05点06分 2
level 10
没人啊
2014年06月21日 10点06分 3
level 10
额 忘贴题目了。
P1001谁拿了最多奖学金Wrong Answer标签:NOIP提高组2005[显示标签]描述
某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,获取的条件各自不同:
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元。
现在给出若干学生的相关数据,请计算哪些同学获得的奖金总数最高(假设总有同学能满足获得奖学金的条件)。
格式输入格式
输入的第一行是一个整数N(1 <= N <= 100),表示学生的总数。接下来的N行每行是一位学生的数据,从左向右依次是姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,以及发表的论文数。姓名是由大小写英文字母组成的长度不超过20的字符串(不含空格);期末平均成绩和班级评议成绩都是0到100之间的整数(包括0和100);是否是学生干部和是否是西部省份学生分别用一个字符表示,Y表示是,N表示不是;发表的论文数是0到10的整数(包括0和10)。每两个相邻数据项之间用一个空格分隔。
输出格式
输出包括三行,第一行是获得最多奖金的学生的姓名,第二行是这名学生获得的奖金总数。如果有两位或两位以上的学生获得的奖金最多,输出他们之中在输入文件中出现最早的学生的姓名。第三行是这N个学生获得的奖学金的总数。
样例1
样例输入1[复制]
4YaoLin 87 82 Y N 0
ChenRuiyi 88 78 N Y 1
LiXin 92 88 N N 0
ZhangQin 83 87 Y N 1
样例输出1[复制]
ChenRuiyi
9000
28700
2014年06月21日 10点06分 4
level 10
我tyvj里过的,上次拿到vijos里评,不知道为什么也没过。。
2014年06月21日 11点06分 5
level 11
弱渣贴个程序
type student=record nam:string; mar,cla,art:longint; wes,lea:boolean; end;var a:array[1..100] of student; f:array[1..100] of longint; n,ans,max,maxj:longint;procedure init;var i:longint; c:char;begin readln(n); for i:=1 to n do begin a[i].nam:=''; read(c); while c<>' ' do begin a[i].nam:=a[i].nam+c; read(c); end; read(a[i].mar); read(a[i].cla); read(c); read(c); if (c='Y')or(c='y') then a[i].lea:=true else a[i].lea:=false; read(c); read(c); if (c='Y')or(c='y') then a[i].wes:=true else a[i].wes:=false; readln(a[i].art); end;end;procedure main;var i:longint;begin max:=-maxlongint; for i:=1 to n do begin f[i]:=0; if (a[i].mar>80)and(a[i].art>=1) then inc(f[i],8000); if (a[i].mar>85)and(a[i].cla>80) then inc(f[i],4000); if a[i].mar>90 then inc(f[i],2000); if (a[i].mar>85)and(a[i].wes=true) then inc(f[i],1000); if (a[i].cla>80)and(a[i].lea=true) then inc(f[i],850); inc(ans,f[i]); if f[i]>max then begin max:=f[i]; maxj:=i; end; end;end;procedure print;begin writeln(a[maxj].nam); writeln(f[maxj]); writeln(ans);end;begin init; main; print;end.
2014年06月21日 13点06分 6
[喷]为什么不换行
2014年06月22日 01点06分
回复 沉默太久水瓶 :我只能说我从vj上copy下来的就成这样子了...
2014年06月22日 04点06分
回复 沉默太久水瓶 :我找一下本地版的
2014年06月22日 04点06分
level 11
type student=record
nam:string;
mar,cla,art:longint;
wes,lea:boolean;
end;
var a:array[1..100] of student;
f:array[1..100] of longint;
n,ans,max,maxj:longint;
procedure init;
var i:longint;
c:char;
begin
readln(n);
for i:=1 to n do begin
a[i].nam:='';
read(c);
while c<>' ' do begin
a[i].nam:=a[i].nam+c;
read(c);
end;
read(a[i].mar);
read(a[i].cla);
read(c);
read(c);
if (c='Y')or(c='y') then a[i].lea:=true else a[i].lea:=false;
read(c);
read(c);
if (c='Y')or(c='y') then a[i].wes:=true else a[i].wes:=false;
readln(a[i].art);
end;
end;
procedure main;
var i:longint;
begin
max:=-maxlongint;
for i:=1 to n do begin
f[i]:=0;
if (a[i].mar>80)and(a[i].art>=1) then inc(f[i],8000);
if (a[i].mar>85)and(a[i].cla>80) then inc(f[i],4000);
if a[i].mar>90 then inc(f[i],2000);
if (a[i].mar>85)and(a[i].wes=true) then inc(f[i],1000);
if (a[i].cla>80)and(a[i].lea=true) then inc(f[i],850);
inc(ans,f[i]);
if f[i]>max then begin
max:=f[i];
maxj:=i;
end;
end;
end;
procedure print;
begin
writeln(a[maxj].nam);
writeln(f[maxj]);
writeln(ans);
end;
begin
init;
main;
print;
end.
2014年06月22日 06点06分 7
1