-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20207.cpp
More file actions
39 lines (35 loc) · 691 Bytes
/
20207.cpp
File metadata and controls
39 lines (35 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
#define FastIO\
ios_base::sync_with_stdio(false);\
cin.tie(NULL);\
cout.tie(NULL);
using namespace std;
int date[367];
int main(){
FastIO;
int n;
cin>>n;
for(int i=0; i<n; i++){
int start, end;
cin>>start>>end;
for(int j=start; j<=end; j++){
date[j]++;
}
}
int area = 0;
int height=0;
int row=0;
for(int i=1; i<=366; i++){
if(date[i]==0){
area += row*height;
row=0;
height=0;
continue;
}
if(date[i]!=0){
row++;
height=max(date[i], height);
}
}
cout<<area;
}