목록알고리즘 풀이/백준 (61)
하다보니
#include using namespace std; #define X first #define Y second int main() { ios::sync_with_stdio(0); cin.tie(0); int n; stack tower; cin >> n; tower.push({ 100000001,0 }); for (int i = 1; i > height; while (tower.top().X < height) tower.pop(); cout
#include using namespace std; int main() { int n; cin >> n; stack s; int cnt = 1; string ans; while (n--) { int t; cin >> t; while (cnt
#include using namespace std; int main() { stack s; int k; int ans = 0; cin >> k; while (k--) { int n; cin >> n; if (n == 0) s.pop(); else s.push(n); } while (!s.empty()) { ans += s.top(); s.pop(); } cout
#include using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; while (n--) { string s; cin >> s; list L; auto cur = L.end(); for (auto c : s) { if (c == '') { if (cur != L.end()) cur++; } else if (c == '-') { if (cur != L.begin()) { cur--; cur = L.erase(cur); } } else { L.insert(cur,c); } } for (auto l : L) { cout
#include using namespace std; int main() { string s; cin >> s; list L; for (auto c : s) L.push_back(c); auto cur = L.end(); int q; cin >> q; while (q--) { char n; cin >> n; if (n == 'P') { char m; cin >> m; L.insert(cur, m); } else if (n == 'L') { if (cur != L.begin()) { cur--; } } else if (n == 'D') { if (cur != L.end()) { cur++; } } else { if (cur != L.begin()) { cur--; cur = L.erase(cur); } }..
#include using namespace std; int num[100000]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, a, x, cnt = 0; cin >> n; for (int i = 0; i > a; num[i] = a; } cin >> x; for (int i = 0; i n; for (int i = 0; i > arr[i]; exist[arr[i]] = true; } cin >> x; for (int ..
#include using namespace std; int num[10]; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; for (auto c : s) { num[c - '0']++; } int sum = num[6] + num[9]; num[6] = sum / 2 + sum % 2; num[9] = 0; int max = num[0]; for (int i = 1; i < 9; i++) { if (max < num[i]) { max = num[i]; } } cout
#include using namespace std; int num[10]; int main() { ios::sync_with_stdio(0); cin.tie(0); int a; int total=1; for (int i = 0; i > a; total *= a; } string l = to_string(total); for (auto c : l) { num[c - '0']++; } for (int i = 0; i < 10; i++)cout
#include using namespace std; int freq[26]; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; for (auto c : s) { freq[c - 'a']++; } for (int i = 0; i < 26; i++)cout