Search
Duplicate
📕

싸이버개강총회

주차
문제번호
19583
언어
C++
티어
실버
유형
구현
자료구조
문자열
해시를 사용한 집합과 맵
nj_Blog
nj_상태
이해도
33%
풀이
사람
이해도 2
13 more properties

문제접근

입력받은 시간을 모두 분으로 바꾸면 편함

놓쳤던 부분

while(cin >> ) 구문

코드

12812 KB

60 ms

#include <iostream> #include <unordered_map> #include <string> using namespace std; int main(void) { string s,e,q; int start, end, quit; string time, name; int tmp; unordered_map<string, int> attendance; int answer = 0; ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> s >> e >> q; start = 60 * stoi(s.substr(0, 2)) + stoi(s.substr(3, 2)); end = 60 * stoi(e.substr(0, 2)) + stoi(e.substr(3, 2)); quit = 60 * stoi(q.substr(0, 2)) + stoi(q.substr(3, 2)); while (cin >> time >> name) { tmp = 60 * stoi(time.substr(0, 2)) + stoi(time.substr(3, 2)); if (tmp <= start) attendance[name] = 1; else if (tmp >= end && tmp <= quit) { if (attendance[name] == 1) { attendance[name]--; answer++; } } } cout << answer; return (0); }
C++
복사