Luo Gu 1051 who took the most scholarship problem solving report

Source: Internet
Author: User

Valley 1051 who took the most scholarships

Address: http://www.luogu.org/problem/show?pid=1051

Title Description

The practice of a school is to grant scholarships after the final exams of each semester. There are five scholarships issued, and the conditions for obtaining them are different:



1) Academician scholarship, 8000 yuan per person, the end of the average score of more than 80 points (>80), and in this semester published 1 or more than 1 papers students can be obtained;

2) May Fourth Scholarship, 4000 yuan per person, the end of the average score is higher than 85 points (>85), and the class appraisal result is higher than 80 (>80) students can be obtained;

3) Outstanding Achievement Award, 2000 yuan per person, students who have a final average score above 90 (>90) can be obtained;

4) Western Scholarship, 1000 yuan per person, and students from western provinces with a final average score above 85 (>85);

5) Class Contribution award, 850 yuan per person, the class appraisal result is higher than 80 points (>80) student cadres can be obtained;



As long as the criteria are met, there is no limit to the number of winners for each scholarship, and a number of scholarships are available for each student. For example, Yiao Lin's end-of-term average is 87 points, Class review score 82 points, and he is a student cadre, then he can also receive May Fourth Scholarship and Class contribution award, the total bonus is 4850 yuan.



Now give the relevant data for several students, please calculate which students get the highest total bonus (assuming that the students can meet the conditions for the scholarship).

Input/output format

Input format:

The first line of the input file scholar.in is an integer N (1 <= n <= 100) that represents the total number of students. The next n rows each row is a student's data, from left to right in turn is the name, the end of the average score, the class appraisal results, whether the student cadre, is the western Province students, as well as the number of papers published. The name is a string of not more than 20 of the length of the letter in the case of uppercase and lowercase letters (without spaces); The final average and class review scores are integers between 0 and 100 (including 0 and 100), whether student cadres and Western provinces students are represented by a single character, y means yes, n means not The number of papers published is 0 to 10 integers (including 0 and 10). Each of the two adjacent data items is separated by a space.

Output format:

The output file Scholar.out includes three lines, the first row is the name of the student who received the most bonus, and the second line is the total number of bonuses that the student received. If there are two or two students who receive the most bonuses, the first student's name appears in the input file. The third line is the total number of scholarships received by these n students.

Input/Output sample

Input Sample # #:

4YaoLin, y n 0ChenRuiyi, n y 1LiXin, n n 0ZhangQin, y n 1

Sample # # of output:

ChenRuiyi900028700
Description

2005 raising the first question of the group

Exercises

Analog + string

According to test instructions, it is easy to think that we can calculate each individual's scholarship to meet the corresponding conditions, and then compare the maximum and sum.

But the difficulty of this problem is not in the program design, but in the realization. Because strings need to be read in READLN, the strings that are read in contain not only names, but also individual information.

So how do you separate numbers or character information from a string? The method used by the author is to enumerate each character in the string, and if it is "" (a space), the current information is copied (the process) and the numeric information is converted to a number using Val (process).

At this point, the problem can be solved.

The following code is attached.

Code
  1. Program Scholar2;
  2. Var
  3. N,q,b,l,mon,sch,sum,i,j,code:longint;
  4. S,t,g,x,nam:string;
  5. Begin
  6. READLN (n);
  7. mon:=0;
  8. sch:=0;
  9. sum:=0;
  10. For i:=1 to n do
  11. begin
  12. READLN (s);
  13. For j:=1 to length (s) do
  14. if s[j]=' Then
  15. begin
  16. T:=copy (S,1,j-1);
  17. Delete (s,1,j);
  18. Break
  19. end;
  20. For j:=1 to length (s) do
  21. if s[j]=' Then
  22. begin
  23. Val (copy (S,1,j-1), q,code);
  24. Delete (s,1,j);
  25. Break
  26. end;
  27. For j:=1 to length (s) do
  28. if s[j]=' Then
  29. begin
  30. Val (copy (S,1,j-1), b,code);
  31. Delete (s,1,j);
  32. Break
  33. end;
  34. G:=copy (S,1,1);
  35. Delete (S,1,2);
  36. X:=copy (S,1,1);
  37. Delete (S,1,2);
  38. Val (S,l,code);
  39. if (q>) and (l>0) Then
  40. begin
  41. Inc (Mon,8000);
  42. Inc (SUM,8000);
  43. end;
  44. if (q>) and (b>) Then
  45. begin
  46. Inc (Mon,4000);
  47. Inc (SUM,4000);
  48. end;
  49. if q>
  50. begin
  51. Inc (Mon,2000);
  52. Inc (SUM,2000);
  53. end;
  54. if (q>) and (x=' Y ') Then
  55. begin
  56. Inc (Mon,1000);
  57. Inc (SUM,1000);
  58. end;
  59. if (b>) and (g=' Y ') Then
  60. begin
  61. Inc (Mon,850);
  62. Inc (SUM,850);
  63. end;
  64. if Mon>sch Then
  65. begin
  66. nam:=t;
  67. Sch:=mon;
  68. mon:=0;
  69. End
  70. else mon:=0;
  71. end;
  72. writeln (NAM);
  73. Writeln (Sch);
  74. writeln (sum);
  75. End.

(This article is the author original, without permission not reproduced)

Luo Gu 1051 who took the most scholarship problem solving report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.