제출 #797764

#제출 시각아이디문제언어결과실행 시간메모리
797764n3rm1nAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
150 ms20072 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 5e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, a, b; vector < pair < int, int > > v, g; void read() { cin >> n; for (int i = 1; i <= n; ++ i) { cin >> a >> b; v.push_back(make_pair(a, b)); } sort(v.begin(), v.end()); for (int i = 0; i < v.size()-1; ++ i) { if(v[i].first != v[i+1].first) g.push_back(v[i]); } g.push_back(v[v.size()-1]); } int cnt[MAXN]; void solve() { n = g.size(); int maxx = -1e9; for (int i = 0; i < n; ++ i) { if(maxx >= g[i].first + g[i].second) cnt[i] ++; maxx = max(maxx, g[i].first + g[i].second); } maxx = -1e9; for (int i = n-1; i >= 0; -- i) { if(maxx >= g[i].second - g[i].first) cnt[i] ++; maxx = max(maxx, g[i].second - g[i].first); } int ans = 0; for (int i = 0; i < n; ++ i) if(!cnt[i])ans ++; cout << ans << endl; } int main() { speed(); read(); solve(); return 0; }

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

Main.cpp: In function 'void read()':
Main.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < v.size()-1; ++ i)
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...