Submission #921643

#TimeUsernameProblemLanguageResultExecution timeMemory
921643vjudge1Lightning Rod (NOI18_lightningrod)C++17
40 / 100
855 ms262144 KiB
#include <bits/stdc++.h> #include <iomanip> #define ll long long #define int long long #define pb push_back #define mp make_pair #define ff first #define ss second #define str string #define pii pair<int,int> #define sz(x) x.size() #define all(x) x.begin(), x.end() #define vi vector<int> #define mii map<int,int> #define mll map<ll,ll> #define yes cout<<"YES\n"; #define no cout<<"NO\n"; #define yess cout<<"Yes\n"; #define noo cout<<"No\n"; using namespace std; #define maxn 1111111 #define mod 1000000007 int u[10000001]; void solve(){ int n; cin>>n; pair<int,int>a[n+3]; set<int>s; for(int i=1;i<=n;i++){ cin>>a[i].ss>>a[i].ff; s.insert(a[i].ss); } if(n>2000){ cout<<s.size(); return; } sort(a+1,a+1+n); for(int i=n;i>=2;i--){ if(u[i]==1){ continue; } for(int j=i-1;j>=1;j--){ //cout<<(abs(a[i].ss-a[j].ss)<=a[i].ff-a[j].ff)<<" "<<a[i].ss<<" "<<a[j].ss<<" "<<a[i].ff<<" "<<a[j].ff<<"\n"; if(abs(a[i].ss-a[j].ss)<=a[i].ff-a[j].ff){ u[j]=1; } } } int ans=0; for(int i=1;i<=n;i++){ ans+=(u[i]==0); } cout<<ans; } signed main(){ ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); //srand( time(0)); //freopen("sum.in", "r", stdin); //freopen("sum.out", "w", stdout); int tests=1; //cin>>tests; for(int i=1;i<=tests;i++){ //cout<<"Case "<<i<<": \n"; solve(); } }
#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...