cout << "soicem" << endl;
=> cout << "soicem" << "\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; int val = 1; vector<int> stk; vector<char> pm; int sp = -1; for (int i = 1; i <= n; i++) { int target; cin >> target; while ((sp == -1 || target > stk[sp]) && n >= val) { stk.push_back(val++); pm.push_back('+'); sp++; } if (target == stk[sp]) { stk.pop_back(); pm.push_back('-'); sp--; } else { cout << "NO"; //system("pause"); return 0; } } for (int i = 0; i < pm.size(); i++) cout << pm[i] << '\n'; return 0; } | cs |
'* Computer Science > Algorithm' 카테고리의 다른 글
baekjun 1966. printerQueue (0) | 2018.08.24 |
---|---|
baekjun 9012. 괄호 (0) | 2018.08.22 |
baekjun 9252. LCS2 (0) | 2018.08.20 |
baekjun 9461. 파도반수열 (0) | 2018.08.14 |
baekjun 11066. 파일 합치기 (0) | 2018.08.14 |