Submission #373826

#TimeUsernameProblemLanguageResultExecution timeMemory
373826guka415Lightning Rod (NOI18_lightningrod)C++14
66 / 100
2094 ms152868 KiB
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <unordered_map> #include <map> using namespace std; typedef pair<int, int> pii; int n; map<int, int, greater<int>> mem; int main() { int x, y, ret = 0, sum, diff; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d", &x, &y); sum = y - x, diff = y + x; if (mem.find(sum) == mem.end() || mem[sum] < diff) mem[sum] = diff; } int prv = -2e9; for (auto ii : mem) { if (prv < ii.second) ret++, prv = ii.second; } printf("%d", ret); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |   scanf("%d %d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...