Ankit_132

B

Oct 21st, 2023
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin>>n;
  10.  
  11.     vector<pair<int, int>> vp(n);
  12.     for(auto &[a, b]: vp)   cin>>a>>b;
  13.  
  14.     int ans = 0;
  15.  
  16.     for(int i=0; i<24; i++)
  17.     {
  18.         int tmp = 0;
  19.  
  20.         for(auto [w, x]: vp)
  21.         {
  22.             if((x+i)%24<=17 && (x+i)%24>=9)
  23.                 tmp += w;
  24.         }
  25.  
  26.         ans = max(ans, tmp);
  27.     }
  28.  
  29.     cout<<ans<<"\n";
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment