fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define int long long
  5. #define yes cout << "YES\n";
  6. #define no cout << "NO\n";
  7.  
  8.  
  9. void FastIO() {
  10. ios_base::sync_with_stdio(false);
  11. cin.tie(nullptr);
  12. cout.tie(nullptr);
  13. }
  14.  
  15. void solve(){
  16. int n,k;
  17. cin >> n >> k;
  18.  
  19. int time = 240 - k;
  20.  
  21. vector<int>cost(n);
  22.  
  23. for(int i = 0; i < n; i++){
  24. cost[i] = 5*(i+1);
  25. if(i)
  26. cost[i] += cost[i-1];
  27. }
  28.  
  29. int l = 0, r = n-1, ans = n, mid;
  30.  
  31. while(l <= r){
  32. mid = (l+r)/2;
  33.  
  34. if(cost[mid] > time){
  35. ans = mid;
  36. r = mid - 1;
  37. }
  38. else
  39. l = mid + 1;
  40. }
  41. cout << ans;
  42. }
  43.  
  44.  
  45. signed main(){
  46. FastIO();
  47.  
  48. int t = 1;
  49. //cin >> t;
  50.  
  51. while (t--){
  52. solve();
  53. }
  54. return 0;
  55. }
Success #stdin #stdout 0s 5320KB
stdin
3 222
stdout
2