# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
537456 | 2022-03-15T06:25:43 Z | tqbfjotld | Planine (COCI21_planine) | C++14 | 3 ms | 724 KB |
#include <bits/stdc++.h> using namespace std; #define int long long int X[1000005]; int Y[1000005]; bool cmp(pair<int,int> a, pair<int,int>b){ if (a.second==b.second) return a.first<b.first; else return a.second<b.second; } main(){ int n,h; scanf("%lld%lld",&n,&h); if (n==3){ printf("0"); return 0; } for (int x = 0; x<n; x++){ scanf("%lld%lld",&X[x],&Y[x]); } vector<pair<int,int> > v; for (int x = 2; x<n-1; x+=2){ v.push_back({X[x]-(h-Y[x])*(X[x]-X[x-1])/(Y[x-1]-Y[x]),X[x]+(h-Y[x])*(X[x+1]-X[x])/(Y[x+1]-Y[x])}); } sort(v.begin(),v.end(),cmp); int cur = v[0].second; int ans = 1; for (auto x : v){ //printf("interval %lld/%lld to %lld/%lld\n",x.first.a,x.first.b,x.second.a,x.second.b); if (x.first<=cur) continue; ans++; cur = x.second; } printf("%lld",ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 596 KB | Output is correct |
2 | Correct | 3 ms | 724 KB | Output is correct |
3 | Incorrect | 3 ms | 724 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 352 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 596 KB | Output is correct |
2 | Correct | 3 ms | 724 KB | Output is correct |
3 | Incorrect | 3 ms | 724 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |