Skip to content

Commit 9bf0a52

Browse files
authored
[20250321] BOJ / G4 / Jigsaw of Shadows / 권혁준
1 parent fb29e88 commit 9bf0a52

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
```cpp
2+
3+
#include <bits/stdc++.h>
4+
using namespace std;
5+
6+
using ld = long double;
7+
8+
int main(){
9+
cin.tie(0)->sync_with_stdio(0);
10+
11+
int theta, N;
12+
cin>>theta>>N;
13+
vector<pair<int,int>> A(N);
14+
for(auto &[x,h]:A) cin>>x>>h;
15+
sort(A.begin(), A.end());
16+
17+
ld t = tan(M_PI * theta / 180.);
18+
ld ans = 0, last = -1;
19+
for(int i=0;i<N;i++){
20+
int x = A[i].first, h = A[i].second;
21+
ld pos = (ld)h / t;
22+
if(last > pos+x) continue;
23+
if(last > x) ans += pos+x-last;
24+
else ans += pos;
25+
last = pos+x;
26+
}
27+
cout<<ans;
28+
29+
}
30+
31+
```

0 commit comments

Comments
 (0)