Submission #426274

#TimeUsernameProblemLanguageResultExecution timeMemory
426274AmylopectinLightning Rod (NOI18_lightningrod)C++14
66 / 100
2058 ms76664 KiB
#include <iostream> #include <stdio.h> using namespace std; const int mxn = 1e7 + 10; struct we { int xx,yy; }; struct we a[mxn] = {}; int main() { ios::sync_with_stdio(false); int i,j,n,m,ru = -1,cx,cy; scanf("%d",&n); for(i=0; i<n; i++) { scanf("%d %d",&cx,&cy); while(ru >= 0 && cx - a[ru].xx <= cy - a[ru].yy) { ru --; } if(ru == -1 || cx - a[ru].xx > a[ru].yy - cy) { ru ++; a[ru] = {cx,cy}; } } printf("%d\n",ru + 1); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:13:11: warning: unused variable 'j' [-Wunused-variable]
   13 |     int i,j,n,m,ru = -1,cx,cy;
      |           ^
lightningrod.cpp:13:15: warning: unused variable 'm' [-Wunused-variable]
   13 |     int i,j,n,m,ru = -1,cx,cy;
      |               ^
lightningrod.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
lightningrod.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d %d",&cx,&cy);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#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...