fork download
  1.  
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. int main(){
  7. int n;
  8. cin >> n;
  9. vector<int> arr;
  10. for(int i = 0; i < n; i++)
  11. {
  12. int x;cin>>x;
  13. arr.push_back(x);
  14. }
  15.  
  16. map<int, int> mp; //duration - frequenct
  17.  
  18. for(int i = 0; i < arr.size(); i++)
  19. {
  20. mp[arr[i]]++;
  21. }
  22.  
  23. vector<int> check(1005, 0);
  24. int res = 0;
  25.  
  26. for(int i=1; 60 * i < 2000; i++)
  27. {
  28. int val = 60 * i;
  29. for(auto it: mp)
  30. {
  31. int exist = val - it.first;
  32. if(exist < 0)
  33. break;
  34. //10 50 20 40 70
  35.  
  36. if(check[exist] == 1)
  37. {
  38. if(check[it.first] == 1)
  39. break;
  40. }
  41.  
  42. if(mp.find(exist) != mp.end())
  43. {
  44. cout << exist << " " << it.second <<endl;
  45. res += (mp[exist] * it.second);
  46. check[exist] = 1;
  47. check[it.first] = 1;
  48. }
  49. }
  50. }
  51. cout << res;
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0.01s 5532KB
stdin
Standard input is empty
stdout
Standard output is empty