Submission #921649

# Submission time Handle Problem Language Result Execution time Memory
921649 2024-02-04T08:46:34 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
40 / 100
2000 ms 262144 KB
#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;
    if(n<=2000){
        pair<int,int> a[n+3];
        int h;
        for(int i=1;i<=n;i++){
            cin>>a[i].ss>>a[i].ff;
        }
        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;
        return;
    }
    int h;
    set<int>s;
    for(int i=1;i<=n;i++){
        cin>>h;
        s.insert(h);
    }
    cout<<s.size();
    return;
}

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();
	}
}


Compilation message

lightningrod.cpp: In function 'void solve()':
lightningrod.cpp:32:13: warning: unused variable 'h' [-Wunused-variable]
   32 |         int h;
      |             ^
# Verdict Execution time Memory Grader output
1 Incorrect 1932 ms 262144 KB Output isn't correct
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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 420 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Incorrect 71 ms 9032 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2023 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1932 ms 262144 KB Output isn't correct
2 Halted 0 ms 0 KB -