fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <algorithm>
  5. #include <limits>
  6. #include <vector>
  7. #include <bitset>
  8. #include <cstdlib>
  9. #include <cstdio>
  10. #include <cstring>
  11. #include <time.h>
  12. using namespace std;
  13. #define si(n) scanf("%d",&n)
  14. #define gc getchar_unlocked
  15. #define pc(x) putchar_unlocked(x)
  16. #define LL long long
  17. #define ULL unsigned long long
  18. #define LD long double
  19.  
  20. int main()
  21. {
  22. #ifdef debug
  23. freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  24. freopen("log.txt", "w", stderr);
  25. #endif
  26. int t,i,j,N,K;
  27. scanf("%d",&t);
  28.  
  29. int maxquality[7];
  30. for(int i =0;i<7;i++)
  31. maxquality[i]=-1;
  32. si(N);
  33. int min=1000000000,price,type,quality,mintype;
  34. while(t--)
  35. {
  36. si(type); si(price);si(quality);
  37. // map<int,int>
  38. if(maxquality[type]<quality)
  39. maxquality[type]=quality;
  40.  
  41. }//end while
  42. for(i=1;i<7;i++){
  43. if(min>maxquality[i]){
  44. min=maxquality[i];
  45. mintype=i;
  46. // cout<<"min"<<i<<" "<<min<<endl;
  47. }
  48. }
  49. if(min==-1)
  50. min=0;
  51. cout<<min;
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0s 3100KB
stdin
7 53
5 8 2
2 4 8
6 8 13
1 13 12
4 5 1
3 2 7
3 13 5
stdout
1