답안 #824451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824451 2023-08-14T06:29:43 Z devariaota Lightning Rod (NOI18_lightningrod) C++17
54 / 100
2000 ms 156256 KB
# include <bits/stdc++.h>
# define int long long
# define vi vector<int>
# define pb push_back
# define pii pair<int, int>
# define fi first
# define se second
# define endl '\n'
# define jess ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int n, x[10000005], y[10000005];
set<pii> s;

void solve() {
    cin >> n;
    bool ok=1;
    int mx=0, mn=1e9;
    for(int i=1; i<=n; i++) {
        cin >> x[i] >> y[i];
        if(y[i]!=1) ok=0;
        mx=max(mx, y[i]);
        mn=min(mn, y[i]);
    }
    if(ok) {
        cout << n << endl;
        return;
    }
    if((mx-mn)<=1) {
        int cnt=0;
        for(int i=1; i<=n; i++) {
            if(y[i]==1) cnt++;
            else {
                if(y[i-1]!=1 && y[i+1]!=1) cnt++;
            }
        }
        cout << cnt << endl;
        return;
    }
    for(int i=1; i<=n; i++) {
        s.insert({y[i], x[i]});
    }
    int ans=0;
    while(!s.empty()) {
        pii cur=*s.rbegin();
        ans++;
        vector<pii> v;
        for(pii i : s) {
            if(abs(i.se-cur.se)<=(cur.fi-i.fi)) {
                v.pb(i);
            }
        }
        for(pii i : v) s.erase(i);
    }
    cout << ans << endl;
}
 
signed main() {
    jess;
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1104 ms 152156 KB Output is correct
2 Correct 1119 ms 151556 KB Output is correct
3 Correct 1061 ms 147488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 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 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 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 340 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 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 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 340 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 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 11 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 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 340 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 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 11 ms 492 KB Output is correct
14 Correct 156 ms 18924 KB Output is correct
15 Correct 676 ms 15636 KB Output is correct
16 Execution timed out 2051 ms 14608 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1206 ms 156256 KB Output is correct
2 Correct 1331 ms 156032 KB Output is correct
3 Correct 1073 ms 152444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1104 ms 152156 KB Output is correct
2 Correct 1119 ms 151556 KB Output is correct
3 Correct 1061 ms 147488 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 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 340 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 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 3 ms 468 KB Output is correct
16 Correct 11 ms 492 KB Output is correct
17 Correct 156 ms 18924 KB Output is correct
18 Correct 676 ms 15636 KB Output is correct
19 Execution timed out 2051 ms 14608 KB Time limit exceeded
20 Halted 0 ms 0 KB -