Submission #426277

#TimeUsernameProblemLanguageResultExecution timeMemory
426277AmylopectinLightning Rod (NOI18_lightningrod)C++14
66 / 100
2089 ms76724 KiB
#include <iostream> #include <stdio.h> #include <stdlib.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); cin.tie(); int i,j,n,m,ru = -1,cx,cy; cin >> n; // scanf("%d",&n); for(i=0; i<n; i++) { cin >> cx >> cy; // 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}; } } cout << ru + 1 << endl; // printf("%d\n",ru + 1); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:15:11: warning: unused variable 'j' [-Wunused-variable]
   15 |     int i,j,n,m,ru = -1,cx,cy;
      |           ^
lightningrod.cpp:15:15: warning: unused variable 'm' [-Wunused-variable]
   15 |     int i,j,n,m,ru = -1,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...