zoukankan      html  css  js  c++  java
  • hdu 1084 排序

    1. #include <stdio.h>
    2. #include <iostream>
    3. #include <string>
    4. #include <stdlib.h>
    5. using namespace std;
    6. #define mark student
    7. #define que solve
    8. struct student
    9. {
    10. int solve;
    11. int time;
    12. int grade;
    13. int set;
    14. };
    15. int cmp(const void *a, const void *b )
    16. {
    17. if((*(student *)a).solve != (*(student *)b).solve)
    18. return (*(mark *)b).que-(*(mark *)a).que;
    19. return (*(mark *)a).time-(*(mark *)b).time;
    20. }
    21. int main()
    22. {
    23. int n;
    24. while( ~scanf("%d", &n) && n!= -1)
    25. {
    26. student list[110];
    27. student *p[110];
    28. int num[6];
    29. memset(num, 0, sizeof(num) );
    30. for(int i=0; i<n; i++)
    31. {
    32. int hour, minute, second;
    33. scanf("%d %d:%d:%d", &list[i].solve, &hour, &minute, &second);
    34. list[i].time = hour*60*60 +minute * 60 +second;
    35. num[list[i].solve] ++;
    36. list[i].set =i;
    37. }
    38. qsort(list, n, sizeof(list[0]), cmp);
    39. int count =0;
    40. for(int i=5; i>=0; i--)
    41. {
    42. if(i == 0)
    43. for(int i=0; i<num[0]; i++) list[count++].grade = 50;
    44. else if(i == 5)
    45. for(int i=0; i<num[5]; i++) list[count++].grade = 100;
    46. else
    47. {
    48. for(int j=1; j<=num[i]; j++)
    49. {
    50. if(j<=num[i]/2)
    51. list[count++].grade = (i+5)*10+5;
    52. else
    53. list[count++].grade = (i+5)*10;
    54. }
    55. }
    56. }
    57. for(int i=0; i<n; i++)
    58. {
    59. for(int j=0; j<n; j++)
    60. {
    61. if(list[j].set == i) printf("%d ", list[j].grade);
    62. }
    63. }
    64. printf(" ");
    65. }
    66. return 0;
    67. }
    68. /*
    69. Problem Description
    70. “Point, point, life of student!”
    71. This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.
    72. There are 5 problems in this final exam. And I will give you 100 points if you can solve all 5 problems; of course, it is fairly difficulty for many of you. If you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former(前者) only when your rank is in the first half of all students who solve 4 problems). Analogically(以此类推), you can get 85、80、75、70、65、60. But you will not pass this exam if you solve nothing problem, and I will mark your score with 50.
    73. Note, only 1 student will get the score 95 when 3 students have solved 4 problems.
    74. I wish you all can pass the exam!
    75. Come on!
    76. Input
    77. Input contains multiple test cases. Each test case contains an integer N (1<=N<=100, the number of students) in a line first, and then N lines follow. Each line contains P (0<=P<=5 number of problems that have been solved) and T(consumed time). You can assume that all data are different when 0<p.
    78. A test case starting with a negative integer terminates the input and this test case should not to be processed.
    79. Output
    80. Output the scores of N students in N lines for each case, and there is a blank line after each case.
    81. Sample Input
    82. 4
    83. 5 06:30:17
    84. 4 07:31:27
    85. 4 08:12:12
    86. 4 05:23:13
    87. 1
    88. 5 06:30:17
    89. -1
    90. Sample Output
    91. 100
    92. 90
    93. 90
    94. 95
    95. 100
    96. */





    附件列表

    • 相关阅读:
      DropDownList判断值是否存在下拉列表中
      postgre教程
      Cookie seesion 赋值
      Winform定时启动
      ASP.NET数据绑定控件
      ASP.NET常用数据绑定控件优劣总结
      Cards and Joy (dp好题)
      River Hopscotch (二分)
      剪花布条(KMP入门)
      GCD (区间数的质因子打表+容斥原理)
    • 原文地址:https://www.cnblogs.com/sober-reflection/p/2594640784ee529175128cc34c9344a0.html
    Copyright © 2011-2022 走看看