Submission #373039

# Submission time Handle Problem Language Result Execution time Memory
373039 2021-03-03T06:41:12 Z sam571128 Planine (COCI21_planine) C++14
0 / 110
63 ms 32768 KB
#include <bits/stdc++.h>

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 1e6+5;
const double EPS = 1e-7;
pair<double,double> seg[N];
double L[N], R[N];
int st[N], id[N];
int n, h;
double findp(int x1, int y1, int x2, int y2){
	assert(y1!=y2);
	return 1.0*(h-y1)*(x2-x1)/(y2-y1)+x1;
}

signed main(){
	fastio
	freopen("input.in","r",stdin);
	cin >> n >> h;
	vector<pair<double,double>> v(1);
	for(int i = 1;i <= n;i++){
		int x,y;
		cin >> x >> y;
		v.push_back({x,y});
	}
    for (int i = 3; i <= n; i+=2) {
        seg[i/2].first = findp(v[i].first,v[i].second, v[i-1].first, v[i-1].second);
    }
    for (int i = n-2; i >= 1; i-=2) {
        seg[i/2].second = findp(v[i].first,v[i].second, v[i+1].first, v[i+1].second);
    }
    sort(seg+1,seg+(n-2)/2,[&](pair<double,double> a, pair<double,double> b){
    	return a.second < b.second;
    });
    double tmp = seg[0].second;
    int ans = 1;

    for (int i = 1; i <= n / 2 - 1; ++i) {
        if (tmp >= seg[i].first)
            continue;

        tmp = seg[i].second;
        ++ans;
    }
    cout << ans << "\n";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:21:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  freopen("input.in","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 32768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 63 ms 32748 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 32768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -