Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- /// from HUNG MINE with love <3
- int s[100001], a[100001], n;
- int main () {
- if (fopen ("test.inp", "r")) {
- freopen ("test.inp", "r", stdin);
- }
- // else {
- // freopen (".inp", "r", stdin);
- // freopen (".out", "w", stdout);
- // }
- ios_base :: sync_with_stdio (0);
- cin.tie (0);
- cout.tie (0);
- cin >> n;
- for (int i = 1; i <= n; ++ i) {
- cin >> a[i];
- }
- for (int i = 1; i <= n; ++ i) {
- s[i] = s[i - 1] + a[i];
- }
- if (a[n] == 1) return cout << "NO", 0;
- if (a[n] == 0 && a[n - 1] == 0 && s[n - 2] == n - 2) return cout << "NO", 0;
- cout << "YES\n";
- for (int i = 1; i < n - 1; ++ i) {
- cout << "(" << a[i] << "->";
- }
- cout << a[n - 1];
- for (int i = 1; i < n - 1; ++ i) {
- cout << ")";
- }
- if (n != 1) {
- cout << "->0";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement