# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
537487 |
2022-03-15T07:15:01 Z |
joelau |
Planine (COCI21_planine) |
C++14 |
|
230 ms |
24692 KB |
#include <bits/stdc++.h>
using namespace std;
int N,H;
pair<int,int> A[1000005];
vector< pair<long double,long double> > lst;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> N >> H;
for (int i = 0; i < N; ++i) cin >> A[i].first >> A[i].second;
for (int i = 2; i < N-1; i += 2) {
long double x1 = A[i].first - (long double) (A[i].first - A[i-1].first) / (A[i-1].second - A[i].second) * (H - A[i].second);
long double x2 = A[i].first + (long double) (A[i+1].first - A[i].first) / (A[i+1].second - A[i].second) * (H - A[i].second);
lst.emplace_back(x2,x1);
}
sort(lst.begin(),lst.end());
int ans = 0;
long double n = -1e18;
for (auto x: lst) if (n < x.second) ans++, n = x.first;
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
3 ms |
724 KB |
Output is correct |
3 |
Correct |
6 ms |
724 KB |
Output is correct |
4 |
Correct |
20 ms |
3196 KB |
Output is correct |
5 |
Correct |
21 ms |
3280 KB |
Output is correct |
6 |
Correct |
21 ms |
3248 KB |
Output is correct |
7 |
Correct |
183 ms |
24652 KB |
Output is correct |
8 |
Correct |
230 ms |
24692 KB |
Output is correct |
9 |
Correct |
213 ms |
24668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
3 ms |
724 KB |
Output is correct |
3 |
Correct |
6 ms |
724 KB |
Output is correct |
4 |
Correct |
20 ms |
3196 KB |
Output is correct |
5 |
Correct |
21 ms |
3280 KB |
Output is correct |
6 |
Correct |
21 ms |
3248 KB |
Output is correct |
7 |
Correct |
183 ms |
24652 KB |
Output is correct |
8 |
Correct |
230 ms |
24692 KB |
Output is correct |
9 |
Correct |
213 ms |
24668 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |