This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define two pair<int,int>
#define pb push_front
#define f first
#define s second
#define sz(container) (int)(container.size())
inline int bin(){
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 n;
deque<two>st;
int main(){
n=bin();
while(n--){
int x=bin();
int y=bin();
bool ok=1;
while(!st.empty()){
int a=st.front().f;
int b=st.front().s;
if(x-a<=b-y){
ok=0;
break;
}
if(x-a<=y-b){
st.pop_front();
}else{
break;
}
}
if(ok){
st.pb({x,y});
}
}
printf("%d\n",sz(st));
// you should actually read the stuff at the bottom
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?), slow multiset operations
* do smth instead of nothing and stay organized
* unordered_map, hash_map, scanf, calculate answer instead of ans*K
*/
/*
* *
* * * *
* * * *
* * * *
* * * * *
* * * *
* * * *
* * *
* *
*/
Compilation message (stderr)
lightningrod.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("unroll-loops")
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |