Submission #896212

# Submission time Handle Problem Language Result Execution time Memory
896212 2024-01-01T02:53:32 Z 8pete8 Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1328 ms 175944 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<float.h>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
#define int long long
#define double long double
const int mod=998244353,mxn=1e6,lg=22;//inf=1e18,minf=-1e18,Mxn=100000;
int32_t main(){
    fastio
	int n;cin>>n;
	stack<pii>st;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		while(!st.empty()&&b-abs(a-st.top().f)>=st.top().s)st.pop();
		if(st.empty()||st.top().s-(abs(a-st.top().f))<b)st.push({a,b});
	}
	cout<<st.size();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1116 ms 160984 KB Output is correct
2 Correct 1136 ms 159152 KB Output is correct
3 Correct 1072 ms 154872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 30 ms 4016 KB Output is correct
15 Correct 27 ms 3668 KB Output is correct
16 Correct 28 ms 4476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1112 ms 103300 KB Output is correct
2 Correct 1099 ms 102336 KB Output is correct
3 Correct 1076 ms 100264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1116 ms 160984 KB Output is correct
2 Correct 1136 ms 159152 KB Output is correct
3 Correct 1072 ms 154872 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 30 ms 4016 KB Output is correct
18 Correct 27 ms 3668 KB Output is correct
19 Correct 28 ms 4476 KB Output is correct
20 Correct 1112 ms 103300 KB Output is correct
21 Correct 1099 ms 102336 KB Output is correct
22 Correct 1076 ms 100264 KB Output is correct
23 Correct 1328 ms 175944 KB Output is correct
24 Correct 1270 ms 157044 KB Output is correct
25 Correct 1221 ms 143132 KB Output is correct