Advertisement
hung_mine

550E

Oct 9th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. /// from HUNG MINE with love <3
  4. int s[100001], a[100001], n;
  5. int main () {
  6.       if (fopen ("test.inp", "r")) {
  7.             freopen ("test.inp", "r", stdin);
  8.       }
  9. //      else {
  10. //            freopen (".inp", "r", stdin);
  11. //            freopen (".out", "w", stdout);
  12. //      }
  13.  
  14.       ios_base :: sync_with_stdio (0);
  15.       cin.tie (0);
  16.       cout.tie (0);
  17.       cin >> n;
  18.       for (int i = 1; i <= n; ++ i) {
  19.             cin >> a[i];
  20.       }
  21.       for (int i = 1; i <= n; ++ i) {
  22.             s[i] = s[i - 1] + a[i];
  23.       }
  24.       if (a[n] == 1) return cout << "NO", 0;
  25.       if (a[n] == 0 && a[n - 1] == 0 && s[n - 2] == n - 2) return cout << "NO", 0;
  26.       cout << "YES\n";
  27.       for (int i = 1; i < n - 1; ++ i) {
  28.             cout << "(" << a[i] << "->";
  29.       }
  30.       cout << a[n - 1];
  31.       for (int i = 1; i < n - 1; ++ i) {
  32.             cout << ")";
  33.       }
  34.       if (n != 1) {
  35.             cout << "->0";
  36.       }
  37.  
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement