# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
541368 | 2022-03-23T09:19:37 Z | AlperenT | Planine (COCI21_planine) | C++17 | 3 ms | 980 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int n, h, ans; pair<long long, long long> arr[N]; vector<pair<long double, long double>> v; long double l, r, mn; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); cin >> n >> h; for(int i = 1; i <= n; i++) cin >> arr[i].first >> arr[i].second; for(int i = 3; i <= n - 2; i += 2){ l = arr[i].first - ((long double)h / (arr[i - 1].second - arr[i].second)) * (arr[i].first - arr[i - 1].first); r = arr[i].first + ((long double)h / (arr[i + 1].second - arr[i].second)) * (arr[i + 1].first - arr[i].first); v.push_back({l, r}); } sort(v.begin(), v.end()); mn = v[0].second; for(int i = 1; i < v.size(); i++){ if(mn < v[i].first){ ans++; mn = v[i].second; } else mn = min(mn, v[i].second); } cout << ans + 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 980 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 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 | Incorrect | 3 ms | 980 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |