개발자 톡
연습문제 톡
[21년 재직자 대회 예선] 회의실 예약
회의실 예약 반례 부탁드립니다ㅜㅜ
- 등록일
- 2023-03-07 15:38:42
- 조회수
- 629
- 작성자
- ahrngs011
제약조건이나 엣지값이 안 맞는지 30점 나오네요,,ㅜㅜ
#include
#include
#include
#include
#include
using namespace std;
void check_time(vector> &ava_time, int index, int start, int end) {
for (int i = start; i < end; i++) {
for (int j = 0; j < ava_time[index].size(); j++) {
if (ava_time[index][j] == i)ava_time[index].erase(ava_time[index].begin() + j);
}
}
}
int main() {
int num_room, use_room;
cin >> num_room >> use_room;
vector> ava_time;
vector rooms;
string a;
//9-18
for (int i = 0; i < num_room; i++) {
cin >> a;
rooms.push_back(a);
vector hours = { 9,10,11,12,13,14,15,16,17,18 };
ava_time.push_back(hours);
}
sort(rooms.begin(), rooms.end());
for (int j = 0; j < use_room; j++) {
cin >> a;
int bg, en, index = 0;
cin >> bg >> en;
for (int k = 0; k < num_room; k++) {
if (rooms[k] == a) index = k;
}
check_time(ava_time,index, bg, en);
}
for (int i = 0; i < num_room; i++) {
cout << "Room "< ans;
for (int j = 9; j <= 18; j++) {
if (ran == 18) {
cout << "Not available" << endl;
break;
}
if (ava_time[i][where] == j && j!=18) {
count++;
where++;
}
else if (ava_time[i][where] == 18 && j==18) {
if (count != 0) {
string aa = to_string(j - count) + "-" + to_string(j);
ans.push_back(aa);
avail++;
}
}
else {
if (count != 0) {
string aa;
if(j-count == 9) aa = "09-" + to_string(j);
else aa = to_string(j - count) + "-" + to_string(j);
ans.push_back(aa);
avail++;
}
count = 0;
}
}
if (avail != 0) {
cout << avail << " available:" << endl;
for (int ll = 0; ll < ans.size(); ll++) cout << ans[ll] << endl;
}
if(i != num_room-1) cout <<"-----"<< endl;
}
return 0;
}
#[21년_재직자_대회_예선]_회의실_예약
#c++
#회의실예약