fork download
  1. #include<iostream>
  2. #include<algorithm>
  3.  
  4. using namespace std;
  5.  
  6. const int khoa[4] = {2, 0, 2, 5};
  7. int a[0];
  8.  
  9. main(){
  10. for (int i = 0; i < 4; i++) {
  11. cin >> a[i];
  12. }
  13. int dem = 0;
  14. for (int i = 0; i < 4; i++) {
  15. int an = a[i] - khoa[i];
  16. if (an < 0) an = an*(-1);
  17. dem = dem + min(an, khoa[i] - a[i] +10);
  18. }
  19.  
  20. cout << dem << endl;
  21. }
  22.  
Success #stdin #stdout 0.01s 5288KB
stdin
0 0 0 1
stdout
8