Submission #141080

#TimeUsernameProblemLanguageResultExecution timeMemory
141080tincamateiLightning Rod (NOI18_lightningrod)C++14
100 / 100
639 ms188208 KiB
#include <bits/stdc++.h> const int BUFF = 1 << 12; const int MAX_N = 10000000; int cursor = BUFF - 1; char buff[BUFF]; char getChar(FILE *fin) { cursor++; if(cursor == BUFF) { cursor = 0; fread(buff, 1, BUFF, fin); } return buff[cursor]; } int getnr(FILE *fin) { char ch = getChar(fin); while(!isdigit(ch)) ch = fgetc(fin); int nr = 0; while(isdigit(ch)) { nr = nr * 10 + ch - '0'; ch = getChar(fin); } return nr; } struct Point { int x, y; } v[MAX_N]; int main() { int N, x, y; Point pnt; N = getnr(stdin); int top = 0; for(int i = 0; i < N; ++i) { x = getnr(stdin); y = getnr(stdin); pnt = {x - y, x + y}; while(top > 0 && pnt.x <= v[top - 1].x && pnt.y >= v[top - 1].y) --top; if(top == 0 || (top > 0 && !(v[top - 1].x <= pnt.x && v[top - 1].y >= pnt.y))) v[top++] = pnt; } printf("%d", top); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'char getChar(FILE*)':
lightningrod.cpp:13:8: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   fread(buff, 1, BUFF, fin);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
#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...