Submission #373837

#TimeUsernameProblemLanguageResultExecution timeMemory
373837guka415Lightning Rod (NOI18_lightningrod)C++14
66 / 100
2055 ms76104 KiB
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> using namespace std; typedef pair<int, int> pii; const int sz = 1e7 + 5; int n; int p[sz][2]; int mxx[sz], mny[sz]; int main() { int xp, yp, ret = 0, mx = -2e9; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d", &xp, &yp); p[i][0] = xp + yp; p[i][1] = xp - yp; } mxx[0] = p[0][0]; for (int i = 1; i < n; i++) mxx[i] = (mxx[i - 1] < p[i][0] ? p[i][0] : mxx[i - 1]); mny[n - 1] = p[n - 1][1]; for (int i = n - 2; i >= 0; i--) mny[i] = (mny[i + 1] > p[i][1] ? p[i][1] : mny[i + 1]); for (int i = 1; i < n - 1; i++) ret += (mxx[i - 1]<p[i][0] && mny[i + 1]>p[i][1]); ret += (mny[1] > p[0][1]); ret += (mxx[n - 2] < p[n - 1][0]); printf("%d", ret); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:15:23: warning: unused variable 'mx' [-Wunused-variable]
   15 |  int xp, yp, ret = 0, mx = -2e9;
      |                       ^~
lightningrod.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |   scanf("%d %d", &xp, &yp);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
#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...