제출 #1123318

#제출 시각아이디문제언어결과실행 시간메모리
1123318Neco_arcAdvertisement 2 (JOI23_ho_t2)C++17
33 / 100
637 ms69212 KiB
#include <bits/stdc++.h> #define ll long long #define name "Advertisement" #define all(x) x.begin(), x.end() #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r #define fi(i, a, b) for(int i = a; i <= b; ++i) #define fid(i, a, b) for(int i = a; i >= b; --i) #define maxn (int) (1e6 + 7) using namespace std; int n; pair<int, int> a[maxn]; vector<int> Comp; struct IT { ll st[4 * maxn]; IT() { memset(st, -60, sizeof st); } void update(int x, ll val, int id = 1, int l = 1, int r = n) { if(l > x || r < x) return; if(l == r) return st[id] = val, void(); int mid = (l + r) >> 1; update(x, val, _left), update(x, val, _right); st[id] = max(st[id * 2], st[id * 2 + 1]); } ll get(int u, int v, int id = 1, int l = 1, int r = n) { if(l > v || r < u) return -1e18; if(u <= l && r <= v) return st[id]; int mid = (l + r) >> 1; return max(get(u, v, _left), get(u, v, _right)); } } StMax, StMin; void solve() { cin >> n; fi(i, 1, n) cin >> a[i].first >> a[i].second; fi(i, 1, n) Comp.push_back(a[i].first); sort(all(Comp)); Comp.resize(unique(all(Comp)) - Comp.begin()); sort(a + 1, a + 1 + n, [](pair<int, int> x, pair<int, int> y) { return x.second > y.second; }); int ans = 0; fi(i, 1, n) { int x = a[i].first, e = a[i].second; int it = upper_bound(all(Comp), x) - Comp.begin(); int ok = 1; if( StMax.get(1, it) >= x + e) ok = 0; if(-StMin.get(it, n) <= x - e) ok = 0; ans += ok; StMax.update(it, x + e); StMin.update(it, -(x - e)); } cout << ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); if(fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } solve(); }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:80:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...