Josif_tepe

Untitled

Nov 13th, 2025
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.    
  7.     int x;
  8.     cin >> x;
  9.    
  10.     int res = 2e9;
  11.    
  12.     for(int d = 0; d <= x; d++) {
  13.         int drveni = 5 * d;
  14.        
  15.         if(drveni >= x) {
  16.             res = min(res, d);
  17.         }
  18.        
  19.         if(drveni <= x) {
  20.             int metalni = (x - drveni + 9) / 10;
  21.            
  22.             if(metalni <= d and drveni + metalni * 10 >= x) {
  23.                 res = min(res, d + metalni);
  24.             }
  25.         }
  26.        
  27.     }
  28.    
  29.     cout << res << endl;
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment