Skip to content

Commit

Permalink
Merge pull request #50 from AlgoLeadMe/16-oesnuj
Browse files Browse the repository at this point in the history
16-oesnuj
  • Loading branch information
oesnuj authored Sep 24, 2024
2 parents 14d57f2 + 1319870 commit 81e6a6d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions oesnuj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
| 13์ฐจ์‹œ | 2024.07.28 | DP | [๋ถ€๋…€ํšŒ์žฅ์ด ๋ ํ…Œ์•ผ](https://www.acmicpc.net/problem/2775) | [#44](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/44) |
| 14์ฐจ์‹œ | 2024.08.05 | ํ•ด์‹œ | [ ๋‚˜๋Š”์•ผ ํฌ์ผ“๋ชฌ ๋งˆ์Šคํ„ฐ ์ด๋‹ค์†œ ](https://www.acmicpc.net/problem/1620) | [#46](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/46) |
| 15์ฐจ์‹œ | 2024.08.10 | ๊ทธ๋ฆฌ๋”” | [ ์ฃผ์‹ ](https://www.acmicpc.net/problem/11501) | [#47](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/47) |
| 16์ฐจ์‹œ | 2024.09.13 | ๊ตฌํ˜„ | [ ๋‹ฌ๋ ฅ ](https://www.acmicpc.net/problem/20207) | [#50](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/50) |
---
42 changes: 42 additions & 0 deletions oesnuj/๊ตฌํ˜„/20207.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <iostream>
#include <vector>
using namespace std;

struct EventPeriod
{
int start, end;
};

int main()
{
int N;
cin >> N;
vector <EventPeriod> 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;
}

0 comments on commit 81e6a6d

Please sign in to comment.