fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. struct isi{
  4. int score1,score2,score3;
  5. string id;
  6. };
  7. bool compar(isi L,isi R){
  8. if(L.score3!=R.score3)return L.score3<R.score3;
  9. if(L.score2!=R.score2)return L.score2<R.score2;
  10. if(L.score1!=R.score1)return L.score1<R.score1;
  11. return 1;
  12. }
  13. isi peserta[84];
  14. int main(){
  15. int tc,m,lolos,ket;
  16. string id;
  17. cin>>tc;
  18. for (int a=1;a<=tc;a++){
  19. cin>>m>>lolos;
  20. cin>>id;
  21. for (int b=1;b<=m;b++){
  22. cin>>peserta[b].id>>peserta[b].score1>>peserta[b].score2>>peserta[b].score3;
  23. }
  24.  
  25. for (int b=1;b<=m;b++){
  26. for (int c=b+1;c<=m;c++){
  27. /*
  28. if (peserta[b].score3<peserta[c].score3){
  29. swap(peserta[b],peserta[c]);
  30. }else if (peserta[b].score3==peserta[c].score3){
  31. if (peserta[b].score2<peserta[c].score2){
  32. swap(peserta[b],peserta[c]);
  33. }else if (peserta[b].score2==peserta[c].score2){
  34. if (peserta[b].score1<peserta[c].score1){
  35. swap(peserta[b],peserta[c]);
  36. }
  37. }
  38.  
  39. }
  40. */
  41. if(compar(peserta[b],peserta[c])==0)
  42. swap(peserta[b],peserta[c]);
  43. }
  44. }
  45. sort(peserta+1,peserta+m+1,compar);
  46. for (int b=0;b<=lolos;b++){
  47. if (peserta[b].id==id){
  48. ket=1;
  49. cout<<"YA"<<endl;
  50. }
  51. }
  52. if (ket==0){
  53. cout<<"TIDAK"<<endl;
  54. }
  55. }
  56. return 0;
  57. }
Success #stdin #stdout 0s 4476KB
stdin
2
3 1
P0001
P0001 10 100 100
P0002 0 0 200
P0003 1 100 100
3 2
P0001
P0001 10 100 100
P0002 0 0 200
P0003 1 100 100
stdout
YA