728x90

전체 글 147

백준 c++ 17952 과제는 끝나지 않아!

17952 과제는 끝나지 않아! 문제풀이 #include #include using namespace std; void fast_io(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { fast_io(); int n, res = 0; stack s; cin >> n; while (n--) { bool num; cin >> num; if (num) //1일때 { int a, b; cin >> a >> b; //점수 소요시간 s.push(make_pair(a, b)); } if (!s.empty()) { s.top().second--; if (s.top().second == 0)//다했으면 이전 과제 {..

백준 c++ 3986 좋은 단어

3986 좋은 단어 문제 풀이 #include #include using namespace std; void fast_io(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { fast_io(); int n, res = 0; cin >> n; while (n--)//입력받은만큼 돈다 { string str; stack s; cin >> str;//문자열 입력받음 s.push(str[0]); //하나를 넣은상태로 시작 for (int i = 1; i < str.size(); i++) { if (!s.empty() && str[i] == s.top()) {//비어있지 않고, 현재 char 가 스택의 top..

백준 c++ 7785 회사에 있는 사람

7785 회사에 있는 사람 문제 풀이 #include #include #include using namespace std; void fast_io(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main(void) { fast_io(); multiset set; //set은 자동정렬된다. 그냥set 과 다른 점은 중복허용 int n; cin >> n; while (n--) { string str1, str2; cin >> str1 >> str2; if (str2 == "enter") set.insert(str1); else set.erase(str1); } for (auto it = set.rbegin(); it..

728x90