- 题解
- 2014-11-06 18:35:04 @
我的代码如下,为何总是wrong answer?
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
int n,i,j;
cin>>n;
string students_name[n];
int final_grade[n],class_grade[n],paper[n],all=0;
char student_cadres,west_student;
int total_money[n];
for(i=0;i<n;i++)
total_money[i]=0;
for(i=0;i<n;i++)
{
cin>>students_name[i]>>final_grade[i]>>class_grade[i]>>student_cadres>>west_student>>paper[i];
if(final_grade[i]<=80)
continue;
if(paper[i]!=0)
total_money[i]+=8000;
if(final_grade[i]>85&&class_grade[i]>80)
total_money[i]+=4000;
if(final_grade[i]>90)
total_money[i]+=2000;
if(final_grade[i]>85&&west_student=='Y')
total_money[i]+=1000;
if(student_cadres=='Y')
total_money[i]+=850;
}
for(i=1;i<n;i++)
{
j=i-1;
int key,k;
string name=students_name[i];
k=i-1;
key=total_money[i];
if(total_money[j]<key&&j>=0)
{
total_money[i]=total_money[j];
students_name[i]=students_name[k];
total_money[j]=key;
students_name[k]=name;
key=total_money[i];
name=students_name[i];
j--;
k--;
}
}
for(i=0;i<n;i++)
{
all+=total_money[i];
}
cout<<students_name[0]<<"\n";
cout<<total_money[0]<<"\n";
cout<<all<<endl;
return 0;
}
3 条评论
-
咖啡中の三叶草 LV 0 @ 2015-11-06 14:51:58
恩恩
-
2014-11-06 19:12:32@
e。。。。窝错了
-
2014-11-06 18:50:14@
为什么发在题解版块里 = =
- 1