Submission #95562

#TimeUsernameProblemLanguageResultExecution timeMemory
95562oolimryLightning Rod (NOI18_lightningrod)C++14
100 / 100
1350 ms144868 KiB
#include <bits/stdc++.h> using namespace std; inline int readInt() { int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9'){ x = (x << 3) + (x << 1) + ch - '0'; ch = getchar(); } return x; } int X[10000000], Y[10000000]; bool in(int a, int b){ /// if b is under a, return true int x1 = X[a]; int x2 = X[b]; int y1 = Y[a]; int y2 = Y[b]; return abs(x1 - x2) <= y1 - y2; } int main(){ //freopen("i.txt.txt","r",stdin); int n = readInt(); for(int i = 0; i < n; i++) { X[i] = readInt(); Y[i] = readInt(); // write code here } // write code here //for(int i = 0;i < n;i++){ //printf("%d %d\n",X[i],Y[i]); //} stack<int> s; if(in(2,3)){ //printf("yes"); } for(int i = 0;i < n;i++){ if(s.empty()){ s.push(i); continue; } else if(in(s.top(),i)){ continue; } else if(in(i,s.top())){ while(!s.empty() && in(i,s.top())){ s.pop(); } s.push(i); } else{ s.push(i); } } printf("%d",s.size()); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:64:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::stack<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d",s.size());
              ~~~~~~~~^
#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...