Submission #400100

# Submission time Handle Problem Language Result Execution time Memory
400100 2021-05-07T10:41:33 Z jenkinsser Planine (COCI21_planine) C++17
0 / 110
3 ms 720 KB
#include <bits/stdc++.h>
#define FOR(ii,aa,bb) for(int ii=aa;ii<bb;ii++)
#define for0(ii,bb) FOR(ii,0,bb)
#define for1(ii,bb) FOR(ii,1,bb+1)
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>
#define piii pair<int,pii>
#define pdi pair<double,int>
#define vi vector<int>
#define sp " "
#define nl "\n"
#define all(x) x.begin(),x.end()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define int ll

using namespace std;

const int N = 1e5+5;
const int INF = 1e9+5;
const int mod = 998244353;

int n,h,L,R,X[N],Y[N];

int calc_left(int x1,int y1,int x2,int y2){
    int difx=x1-x2;
    int dify=y1-y2;
    int difh=h-y1;
    int res=ceil((float)difx*difh/dify);
    // cout << x1 << sp << y1 << sp << x2 << sp << y2 << sp << max(L,x1+res) << nl;
    return max(L,x1+res);
}

int calc_right(int x1,int y1,int x2,int y2){
    int difx=x2-x1;
    int dify=y2-y1;
    int difh=h-y2;
    int res=difx*difh/dify;
    // cout << x1 << sp << y1 << sp << x2 << sp << y2 << sp << min(R,x2+res) << nl;
    return min(R,x2+res);
}

signed main(){
    fastio()
    cin >> n >> h;
    for(int i=1;i<=n;i++){
        cin >> X[i] >> Y[i];
        if(i==1)
            L=X[i];
        if(i==n)
            R=X[i];
    }
    vector<pii> v;
    for(int i=3;i<n;i+=2){
        int l=calc_left(X[i-1],Y[i-1],X[i],Y[i]);
        int r=calc_right(X[i],Y[i],X[i+1],Y[i+1]);
        v.pb({l,r});
    }
    sort(all(v));
    int pos=v[0].nd;
    // cout << pos << nl;
    int ans=1;
    for(int i=1;i<v.size();i++){
        // cout << v[i].st << sp << pos << nl;
        if(v[i].st>pos){
            pos=v[i].nd;
            // cout << pos << nl;
            ans++;
        }
    }
    cout << ans << nl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:67:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i=1;i<v.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 720 KB Output isn't correct
2 Halted 0 ms 0 KB -