제출 #1336696

#제출 시각아이디문제언어결과실행 시간메모리
1336696top1svtinAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
139 ms8268 KiB
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("inline")

#include <bits/stdc++.h>

using namespace std;

#define kien long long
#define pb push_back
#define FOR(i, a, b) for (int i = a;i <= b; i++)
#define FORD(i, a, b) for (int i = a;i >= b; i--)
#define pii pair<int, int>
#define dembit(a) __builtin_popcountll(a)
#define task "kien"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define debug(x) cout << x << " ";
#define down cout << "\n"
const kien MOD = 1e9 + 7;
const int NTEST = 100;
const int Million = 1e6 + 5;
const int MXN = 5e5 + 5;
mt19937 rd(chrono::high_resolution_clock::now().time_since_epoch().count());
kien rand(kien l, kien r) {
    assert(l <= r);
    return uniform_int_distribution<kien>(l, r)(rd);
}

kien n, k, m, dem, vis[MXN + 5], u, v;
pii a[1000000];
kien maxx, minn, vtr, l, r, ans;
pii dp[MXN];

//void sub2() {
//    ans = MOD;
//    FOR (mask, 1, (1 << n) - 1) {
//        kien num = dembit(mask);
//        FOR (i, 1, n) {
//            if ((mask >> i) & 1) {
//                vis[i] = 1;
//                FOR (j, 1, n) {
//                    if (abs(a[i].first - a[j].second) <= a[i].second - a[j].second) {
//                        vis[j] = 1;
//                    }
//                }
//            }
//        }
//
//        bool ktr = true;
//        FOR (i, 1, n) {
//            if (!vis[i]) {ktr = false; break;}
//        }
//        if (ktr) ans = min(ans, num);
//    }
//    cout << ans;
//}

bool cmp (pii x, pii y) {
    if (x.first == y.first) return x.second > y.second;
    return x.first < y.first;
}

void solve() {
    cin >> n;
    FOR (i, 1, n) {
        cin >> a[i].first >> a[i].second;
        dp[i] = {a[i].first - a[i].second, a[i].first + a[i].second};
    }

    sort (dp + 1, dp + 1 + n, cmp);
    maxx = 0;
    FOR (i, 1, n) {
        if (dp[i].second > maxx) {
            ans++;
            maxx = dp[i].second;
        }
    }

    cout << ans;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    if (fopen(task".inp", "r")) {
        fin(task); fou(task);
    }
    int t = 1;  //cin >> t;
    while(t--) solve();

    cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "s ";
}

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

Main.cpp:84:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   84 | main() {
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:17:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:89:9: note: in expansion of macro 'fin'
   89 |         fin(task); fou(task);
      |         ^~~
Main.cpp:18:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:89:20: note: in expansion of macro 'fou'
   89 |         fin(task); fou(task);
      |                    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...