Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16-oesnuj #50

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}