Submission #988831

#TimeUsernameProblemLanguageResultExecution timeMemory
988831HienTDAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
132 ms14160 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; }

Compilation message (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...