답안 #922171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
922171 2024-02-05T07:59:15 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
100 / 100
595 ms 229976 KB
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
//#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define str string
#define pii pair<int,int>
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define mii map<int,int>
#define mll map<ll,ll>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yess cout<<"Yes\n";
#define noo cout<<"No\n";
using namespace std;

#define maxn 2000101
#define mod  1000000007

int gt(){
    int r=0;
    char c=getchar();
    //cout<<c<<"\n";
    while(c==' ' || c=='\n'){
        c=getchar();
      //  cout<<c<<"\n";
    }
    while(c!=' ' && c!='\n'){
        r*=10;
        r+=(c-'0');
        c=getchar();
        //cout<<c<<"\n";
    }
    //cout<<r<<"\n";
    return r;
}

void solve(){
    int n;
    n=gt();
    vector<pair<int,int>> v;
    for(int i=1;i<=n;i++){
        int q,w;
        q=gt();
        w=gt();
        if(v.size()==0){
            v.pb(mp(q,w));
            continue;
        }
        else{
            pair<int,int>p=v.back();
            if(abs(p.ff-q)<=p.ss-w){
                continue;
            }
            while(v.size()){
                pair<int,int>p=v.back();
                if(abs(p.ff-q)<=w-p.ss){
                    v.pop_back();
                }
                else{
                    break;
                }
            }
            v.pb(mp(q,w));
        }
    }
    cout<<v.size();
}

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	//srand( time(0));
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
    int tests=1;
    //cin>>tests;
    for(int i=1;i<=tests;i++){
		//cout<<"Case "<<i<<": \n";
		solve();
	}
}


# 결과 실행 시간 메모리 Grader output
1 Correct 467 ms 229100 KB Output is correct
2 Correct 490 ms 229340 KB Output is correct
3 Correct 453 ms 229976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 492 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 492 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 12 ms 2396 KB Output is correct
15 Correct 12 ms 2360 KB Output is correct
16 Correct 12 ms 2960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 408 ms 115808 KB Output is correct
2 Correct 430 ms 121164 KB Output is correct
3 Correct 429 ms 130692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 467 ms 229100 KB Output is correct
2 Correct 490 ms 229340 KB Output is correct
3 Correct 453 ms 229976 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 492 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 12 ms 2396 KB Output is correct
18 Correct 12 ms 2360 KB Output is correct
19 Correct 12 ms 2960 KB Output is correct
20 Correct 408 ms 115808 KB Output is correct
21 Correct 430 ms 121164 KB Output is correct
22 Correct 429 ms 130692 KB Output is correct
23 Correct 595 ms 175716 KB Output is correct
24 Correct 558 ms 156872 KB Output is correct
25 Correct 539 ms 140668 KB Output is correct