제출 #1299146

#제출 시각아이디문제언어결과실행 시간메모리
1299146tuandqAdvertisement 2 (JOI23_ho_t2)C++20
59 / 100
2094 ms1472 KiB
#include <bits/stdc++.h>
using namespace std ;

typedef long long ll ;
typedef long double ld ;
typedef pair<int, int> pii ;
typedef pair<int, long long> pil ;
typedef pair<long long, int> pli ;
typedef pair<long long, long long> pll ;

#define bitc(n) (__builtin_popcountll(n))
#define clz(n) (__builtin_clzll(n))
#define ctz(n) (__builtin_ctzll(n))
#define lgi(n) (31 - __builtin_clz(n))
#define lgl(n) (63 - __builtin_clzll(n))
#define MASK(k) (1ll << (k))
#define getbit(n, k) ((n) >> (k) & 1)
#define flipbit(n, k) ((n) ^ (1ll << (k)))
#define ton(n, k) ((n) | (1ll << (k)))
#define toff(n, k) ((n) & ~(1ll << (k)))

#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define lwb lower_bound
#define upb upper_bound
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define taskname "input"

template<class X, class Y>
bool maximize(X &x, const Y &y) {
    if(x < y) {
        return x = y, true ;
    }
    return false ;
}

template<class X, class Y>
bool minimize(X &x, const Y &y) {
    if(x > y) {
        return x = y, true ;
    }
    return false ;
}

template<class X>
void removeDup(vector<X> &ve) {
    sort(ve.begin(), ve.end()) ;
    ve.resize(unique(ve.begin(), ve.end()) - ve.begin()) ;
}

const ll INF = 1e18 ;
const int inf = 1e9 ;
const int mod = 1e9 + 7 ;
const int N = 1e5 + 5, LG = 17 ;

/* Some Peach Tea Is Great ;-; */
/* Author : Tuandq */

int n ;
vector<pii> lst ;

void kittncool() {
    cin >> n ;
    for(int i = 1; i <= n; i ++) {
        int x, e ; cin >> x >> e ;
        lst.emplace_back(x, e) ;
    }
    removeDup(lst) ;

    sort(all(lst), [&](auto u, auto v) {
        if(u.se == v.se) return u.fi > v.fi ;
        return u.se > v.se ;
    }) ;
    
    int t = 0 ;

    for(int i = 0; i < sz(lst); i ++) {
        int cn = 0 ;
        for(int j = 0; j < sz(lst); j ++) if(i != j) {
            if(abs(lst[j].fi - lst[i].fi) <= lst[j].se - lst[i].se) ++ cn ;
        }
        if(!cn) ++ t ;
        // if(!cn) cerr << i << ' ' ;
    }
    cout << t ; return ;
    // cerr << endl ;

    int res = 0 ;
    ll add = -INF, sub = -INF ;
    for(auto [x, e] : lst) {
        bool f = maximize(add, 1ll * e + x) ;
        bool g = maximize(sub, 1ll * e - x) ;
        if(f || g) ++ res ;
        cerr << "-> " << x << ' ' << e << ' ' << " | " << add << ' ' << sub << ' ' << res << endl ;
    }
    cout << res ;
}

signed main() {
    ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
    if(fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin) ;
        freopen(taskname".out", "w", stdout) ;
    }

    int t = 1 ; //cin >> t ;
    while(t --) {
        kittncool() ;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:105:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |         freopen(taskname".inp", "r", stdin) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         freopen(taskname".out", "w", stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...