Skip to content

Commit

Permalink
2024-09-13 ๋‹ฌ๋ ฅ
Browse files Browse the repository at this point in the history
  • Loading branch information
oesnuj committed Sep 13, 2024
1 parent 72fc116 commit bc572a4
Showing 1 changed file with 42 additions and 0 deletions.
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 bc572a4

Please sign in to comment.