Submission #829032

# Submission time Handle Problem Language Result Execution time Memory
829032 2023-08-18T02:23:33 Z kebine Lightning Rod (NOI18_lightningrod) C++17
80 / 100
2000 ms 174120 KB
#include <bits/stdc++.h>
typedef long long ll;
#define ii pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;

vector<ii> seg;
bool comp(ii a, ii b){
    if(a.fi == b.fi) return a.se > b.se;
    return a.fi < b.fi;
}

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

    int n;
    cin >> n;
    seg.resize(n);
    ll x, y;
    for(int i=0; i<n; i++){
        cin >> x >> y;
        seg[i] = mp(x-y, x+y);
    }
    sort(seg.begin(), seg.end(), comp);

    ll r=-1e18, R=-1e18, cnt = 0;
    for(int i=0; i<n; i++){
        // cout<<seg[i].fi<<' '<<seg[i].se<<'\n';
        R = max(r, seg[i].se);
        if(seg[i].se > r){
            ++cnt;
            r = R;
        }
    }
    cout << cnt << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1725 ms 166876 KB Output is correct
2 Correct 1696 ms 167020 KB Output is correct
3 Correct 1615 ms 162508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 46 ms 6660 KB Output is correct
15 Correct 43 ms 6672 KB Output is correct
16 Correct 36 ms 5836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1742 ms 174120 KB Output is correct
2 Correct 1765 ms 168460 KB Output is correct
3 Correct 1756 ms 164632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1725 ms 166876 KB Output is correct
2 Correct 1696 ms 167020 KB Output is correct
3 Correct 1615 ms 162508 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 46 ms 6660 KB Output is correct
18 Correct 43 ms 6672 KB Output is correct
19 Correct 36 ms 5836 KB Output is correct
20 Correct 1742 ms 174120 KB Output is correct
21 Correct 1765 ms 168460 KB Output is correct
22 Correct 1756 ms 164632 KB Output is correct
23 Execution timed out 2012 ms 174012 KB Time limit exceeded
24 Halted 0 ms 0 KB -