Advertisement
Saleh127

HDU 1008

Jul 5th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. ll a,c,d,e,f,i,j,k,l;
  10. while(cin>>a && a)
  11. {
  12. c=a*5;
  13. d=0;
  14. for(i=0;i<a;i++)
  15. {
  16. cin>>e;
  17. if(e>d) c+=(e-d)*6;
  18. else c+=(d-e)*4;
  19. d=e;
  20. }
  21. cout<<c<<endl;
  22. }
  23.  
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement