이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define ll long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define mii map<int,int>
#define mll map<long long int, long long int>
#define mivi map<int,vector<int>>
#define f0r(i,n) for(int i=0;i<n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
using namespace std;
bool cmp(pair<pii,int> aa, pair<pii,int> bb){
pii a = aa.first;
pii b = bb.first;
if(a.first < b.first)return 1;
if(a.first > b.first)return 0;
if(a.second > b.second)return 1;
return 0;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
//ifstream cin(".in");
//ofstream cout(".out");
int n;
cin>>n;
vector<pair<pii, int>> v(n);
//vpii sum(n);
//vpii diff(n);
//set<int>s;
f0r(i,n){
int x,e;
cin>>x>>e;
v[i] = {{x-e, x+e}, i};
//sum[i] = e+x;
//s.insert(x);
}
sort(v.begin(), v.end(), cmp);
int mx = -1;
int ans = 0;
//for(auto u : v)cout<<u.first.first<<' '<<u.first.second<<'\n';
f0r(i,n){
if(v[i].first.second > mx){
mx = v[i].first.second;
ans++;
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |