이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
using namespace std;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }
const int mxn = (int)(5e5) + 10;
const int INF = (int)(2e9) + 10;
pii a[mxn];
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
loop(i,0,n){
int x, y;
cin >> x >> y;
a[i] = {x + y, y - x};
}
sort(a, a + n, greater<pii>());
// loop(i,0,n){
// cerr << a[i] << endl;
// }
int y_lim = -INF, ans = 0;
loop(i,0,n){
if(a[i].ss > y_lim){
y_lim = a[i].ss;
ans++;
}
}
cout << ans << '\n';
}
/*
9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
*/
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'std::ostream& operator<<(std::ostream&, std::pair<int, int>)':
Main.cpp:16:84: warning: no return statement in function returning non-void [-Wreturn-type]
16 | ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }
| ^
# | 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... |