제출 #905220

#제출 시각아이디문제언어결과실행 시간메모리
905220PetrixAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
129 ms13924 KiB
#include <cstdio> #include <vector> #include <utility> #include <algorithm> int ri() { int n; scanf("%d", &n); return n; } int main() { int N = ri(); std::vector<std::pair<int, int> > points(N); for (int i = 0; i < N; i++) { int X = ri(); int E = ri(); points[i] = {X - E, X + E}; // {a[i], b[i]} } // a同じならbé™é †ã«ã™ã‚‹ã¨ã€aが同じやつで複数回bの最大値を更新してしまったりしなくなる std::sort(points.begin(), points.end(), [] (auto &i, auto &j) { if (i.first != j.first) return i.first < j.first; return i.second > j.second; }); int max = -1; int cnt = 0; for (auto i : points) if (max < i.second) max = i.second, cnt++; printf("%d\n", cnt); return 0; }

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

Main.cpp: In function 'int ri()':
Main.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d", &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...