fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4.  
  5. const int nmax = 1e6;
  6. int a[nmax + 5];
  7.  
  8. int32_t main() {
  9. int n; cin >> n;
  10. for(int i = 1; i <= n; ++ i) cin >> a[i];
  11.  
  12. int ans = 0, c = 1e18;
  13. for(int i = 1; i <= n; ++ i) {
  14. c = min(a[i], c);
  15. ans += 3 * c;
  16. }
  17. cout << ans;
  18. }
Time limit exceeded #stdin #stdout 5s 5296KB
stdin
Standard input is empty
stdout
Standard output is empty