From bc572a48358828b89f92fe07ad453a3d0a1fa8fb Mon Sep 17 00:00:00 2001 From: Junseo Kim Date: Fri, 13 Sep 2024 17:46:52 +0900 Subject: [PATCH] =?UTF-8?q?2024-09-13=20=EB=8B=AC=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "oesnuj/\352\265\254\355\230\204/20207.cpp" | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "oesnuj/\352\265\254\355\230\204/20207.cpp" diff --git "a/oesnuj/\352\265\254\355\230\204/20207.cpp" "b/oesnuj/\352\265\254\355\230\204/20207.cpp" new file mode 100644 index 0000000..08b6bc3 --- /dev/null +++ "b/oesnuj/\352\265\254\355\230\204/20207.cpp" @@ -0,0 +1,42 @@ +#include +#include +using namespace std; + +struct EventPeriod +{ + int start, end; +}; + +int main() +{ + int N; + cin >> N; + vector v(N); + int days[365] = {0}; + + for(int i = 0; i < N; i++) + { + cin >> v[i].start >> v[i].end; //일정 시작일, 종료일 입력받기 + + for (int k = v[i].start - 1; k < v[i].end; k++) { + days[k]++; //일정에 포함되는 날의 배열 값 +1; + } + } + + int result = 0; + int height = 0, width = 0; + for (int i = 0; i < 365; i++) { + if (days[i] != 0) { + width++; + height = max(height, days[i]); + } + + if (days[i + 1] == 0) { + result += height * width; + width = 0; + height = 0; + } + } + cout << result; + return 0; +} \ No newline at end of file