답안 #541368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541368 2022-03-23T09:19:37 Z AlperenT Planine (COCI21_planine) C++17
0 / 110
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

Main.cpp: In function 'int main()':
Main.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long double, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i = 1; i < v.size(); i++){
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -