이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
map<ll,ll> sus;
FOR(i,0,n){
ll a,b;
cin >> a >> b;
if (sus.count(a))sus[a] = max(sus[a], b);
else sus[a] = b;
}
vector<vector<ll>> stuff;
for (auto&i : sus){
stuff.push_back({i.first-i.second, -(i.first+i.second)});
}
sort(stuff.begin(), stuff.end());
ll ans = 1;
ll maxi = -stuff[0][1];
ll cur = 0;
while (cur < stuff.size()){
while (cur < stuff.size() && -stuff[cur][1] <= maxi) cur++;
if (cur < stuff.size()){
ans++;
maxi = -stuff[cur][1];
cur++;
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:32:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | while (cur < stuff.size()){
| ~~~~^~~~~~~~~~~~~~
Main.cpp:33:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | while (cur < stuff.size() && -stuff[cur][1] <= maxi) cur++;
| ~~~~^~~~~~~~~~~~~~
Main.cpp:34:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | if (cur < stuff.size()){
| ~~~~^~~~~~~~~~~~~~
# | 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... |