Submission #961437

# Submission time Handle Problem Language Result Execution time Memory
961437 2024-04-12T05:57:52 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1458 ms 257692 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ent "\n"

const int maxn = 1e7 + 100;
const ll INF = (ll)1e18 + 100;
const int inf = 1e9 + 100;
const int MOD = 1e9 + 7;
const int maxl = 30;
const int P = 31;

int n;
int a[maxn];
int b[maxn];
bool ok[maxn];

void test(){
	cin >> n;
	int mx = -inf;
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
		if(a[i] + b[i] > mx){
			ok[i] = 1;		}
		mx = max(mx, a[i] + b[i]);
	}
	int mn = inf * 2, cnt = 0;
	for(int i = n; i > 0; i--){
		if(a[i] - b[i] < mn && ok[i]) cnt++;
		mn = min(mn, a[i] - b[i]);
	}
	cout << cnt;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1; t = 1;
	while(t--) test();
	cout << ent;
}
# Verdict Execution time Memory Grader output
1 Correct 1133 ms 144200 KB Output is correct
2 Correct 1133 ms 151896 KB Output is correct
3 Correct 1076 ms 167564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4556 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4556 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4564 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4556 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4564 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 28 ms 12380 KB Output is correct
15 Correct 37 ms 14164 KB Output is correct
16 Correct 26 ms 11352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1137 ms 148968 KB Output is correct
2 Correct 1156 ms 184260 KB Output is correct
3 Correct 1153 ms 181376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1133 ms 144200 KB Output is correct
2 Correct 1133 ms 151896 KB Output is correct
3 Correct 1076 ms 167564 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4556 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4564 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 28 ms 12380 KB Output is correct
18 Correct 37 ms 14164 KB Output is correct
19 Correct 26 ms 11352 KB Output is correct
20 Correct 1137 ms 148968 KB Output is correct
21 Correct 1156 ms 184260 KB Output is correct
22 Correct 1153 ms 181376 KB Output is correct
23 Correct 1458 ms 257692 KB Output is correct
24 Correct 1275 ms 239572 KB Output is correct
25 Correct 1304 ms 220320 KB Output is correct