Submission #515943

#TimeUsernameProblemLanguageResultExecution timeMemory
515943JooLightning Rod (NOI18_lightningrod)C++17
100 / 100
382 ms80056 KiB
#include <bits/stdc++.h>
using namespace std;


inline void read(int& x) {
    x = 0;
    char ch = getchar_unlocked();
    while (ch&16){
		x = (x << 3) + (x << 1) + (ch&15);
		ch = getchar_unlocked();
	}
}

int main(void){
    int n; read(n);
    stack<pair<int, int>> st;

    for(int i = 1; i <= n; i++){
        int x, y; read(x), read(y);
        while(!st.empty() and x-st.top().first <= y-st.top().second) st.pop();
        if(st.empty() or (x-st.top().first > y-st.top().second and x-st.top().first > st.top().second-y)) st.push({x, y});
    }

    printf("%d\n", st.size());

    return 0;
}

Compilation message (stderr)

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