제출 #961298

#제출 시각아이디문제언어결과실행 시간메모리
961298mannshah1211Advertisement 2 (JOI23_ho_t2)C++17
100 / 100
86 ms20488 KiB
#pragma GCC target("avx2,bmi2") #include <bits/stdc++.h> using namespace std; #ifndef ONLINE_JUDGE #define getchar_unlocked() getchar() #endif inline int read() { int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { ch = getchar_unlocked(); } while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + ch - '0'; ch = getchar_unlocked(); } return x; } int x[10000000], y[10000000]; const int inf = 1e9; using T = pair<int, int>; int main() { int n = read(); for (int i = 0; i < n; i++) { x[i] = read(); y[i] = read(); } vector<pair<int, int>> ds(n); for (int i = 0; i < n; i++) { ds[i] = make_pair(x[i] - y[i], x[i] + y[i]); } sort(ds.begin(), ds.end(), [](const T& a, const T& b) { if (a.first == b.first) { return (a.second > b.second); } return (a.first < b.first); }); int mx = -inf, ans = 0; for (int i = 0; i < n; i++) { if (mx < ds[i].second) { ans++; } mx = max(mx, ds[i].second); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...