fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main() {
  5. int n, k = 0;
  6. cin >> n;
  7. vector<int> a(n);
  8. for (int i = 0; i < n; ++i) {
  9. cin >> a[i];
  10. }
  11. for (int i = 0; i < n; ++i) {
  12. k += a[i];
  13. if (k == 0) {
  14. cout << "- ";
  15. }
  16. else {
  17. cout << "+ ";
  18. }
  19. --k;
  20. }
  21. if (k > 0) {
  22. while (k > 0) {
  23. cout << "+ ";
  24. --k;
  25. }
  26. }
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5428KB
stdin
5
0 3 0 0 0
stdout
- + + - +