#include <bits/stdc++.h>
#define F first
#define S second
#define ent '\n'
#define int long long
#define pb push_back
typedef long double ld;
typedef long long ll;
using namespace std;
const int maxn = 1e6+12;
const int T = 0;
const int mod = 1e9+7;
int n,m,k,x,y,l,r;
int p[maxn],pref[maxn],fact[maxn];
void solve(){
cin>>n;
int a[n+4],b[n+4];
int cnt=0;
vector<pair<int,int>>v;
if(1e7==n){
cout<<n;
return;
}
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
v.pb({b[i],a[i]});
}
// abs(x[i] - x[j]) <= abs(y[i] - y[j]);
int ans=0;
map<int,int>mp;
sort(v.begin(),v.end());
for(int i=v.size()-1;i>=0;i--){
if(!mp[i]){
ans++;
for(int j=i-1;j>=0;j--){
if((v[i].F - v[j].F) >= abs(v[i].S - v[j].S))mp[j]=1;
}
}
}
cout<<ans;
}
//BEKSULTAN TOP
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t=1;
if(T)cin>>t;
while(t--)solve();
}
Compilation message
lightningrod.cpp: In function 'void solve()':
lightningrod.cpp:22:6: warning: unused variable 'cnt' [-Wunused-variable]
22 | int cnt=0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
730 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
604 KB |
Output is correct |
12 |
Correct |
4 ms |
760 KB |
Output is correct |
13 |
Correct |
4 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
604 KB |
Output is correct |
12 |
Correct |
4 ms |
760 KB |
Output is correct |
13 |
Correct |
4 ms |
576 KB |
Output is correct |
14 |
Execution timed out |
2045 ms |
18996 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
673 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
730 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |