Advertisement
Ne-Biolog

Untitled

Feb 4th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. //#include <bits/stdc++.h>
  2. #include <algorithm>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <vector>
  6. #include <cmath>
  7. #include <cstdio>
  8. #include <set>
  9.  
  10. #define DEBUG 1
  11. #define TIME clock() / 1.0 / CLOCKS_PER_SEC
  12.  
  13. using namespace std;
  14.  
  15. signed main()
  16. {
  17. #if DEBUG
  18. freopen("input.txt", "r", stdin);
  19. freopen("output.txt" , "w", stdout);
  20. ios_base::sync_with_stdio(false);
  21. #endif
  22.  
  23. int n;
  24. cin >> n;
  25. int *a = new int [n + 1];
  26. int *sum = new int [n + 1];
  27. int *min = new int [n + 1];
  28. sum[0] = 0;
  29. for(int i = 1; i <= n; ++i) {
  30. cin >> a[i];
  31. sum[i] = sum[i - 1] + a[i];
  32. }
  33. min[0] = 0;
  34. for(int i = 1; i <= n; ++i) {
  35. if(i == 1) {
  36. min[i] = sum[i];
  37. } else {
  38. min[i] = min(min[i - 1], sum[i]);
  39. }
  40. }
  41.  
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement