Submission #828917

# Submission time Handle Problem Language Result Execution time Memory
828917 2023-08-17T20:09:25 Z NK_ Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1545 ms 157096 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
 
using namespace std;
 
#define nl '\n'
#define pb push_back 
#define mp make_pair
#define f first
#define s second
#define sz(x) int(x.size())
 
template<class T> using V = vector<T>;
using vi = V<int>;
using ll = long long;
using pi = pair<int, int>;
using vpi = V<pi>;
using vl = V<ll>;
using db = double;

const int INF = 1e9 + 10;

int main() {
	cin.tie(0)->sync_with_stdio(0);

	int N; scanf("%d", &N);

	vpi stk;
	for(int i = 0; i < N; i++) {
		int x, y; scanf("%d %d", &x, &y);
		int l = x - y, r = x + y;

		while(sz(stk) && l <= stk.back().f && stk.back().s <= r) stk.pop_back();
		if (!sz(stk) || stk.back().s < r) stk.pb(mp(l, r));
	}

	cout << sz(stk) << nl;

	exit(0-0);
}					

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  int N; scanf("%d", &N);
      |         ~~~~~^~~~~~~~~~
lightningrod.cpp:30:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   int x, y; scanf("%d %d", &x, &y);
      |             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1403 ms 132548 KB Output is correct
2 Correct 1427 ms 132504 KB Output is correct
3 Correct 1366 ms 132616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 360 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 360 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 32 ms 3788 KB Output is correct
15 Correct 34 ms 3620 KB Output is correct
16 Correct 31 ms 3876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1521 ms 66812 KB Output is correct
2 Correct 1463 ms 66688 KB Output is correct
3 Correct 1488 ms 66564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1403 ms 132548 KB Output is correct
2 Correct 1427 ms 132504 KB Output is correct
3 Correct 1366 ms 132616 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 360 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 32 ms 3788 KB Output is correct
18 Correct 34 ms 3620 KB Output is correct
19 Correct 31 ms 3876 KB Output is correct
20 Correct 1521 ms 66812 KB Output is correct
21 Correct 1463 ms 66688 KB Output is correct
22 Correct 1488 ms 66564 KB Output is correct
23 Correct 1504 ms 20800 KB Output is correct
24 Correct 1545 ms 157096 KB Output is correct
25 Correct 1485 ms 140200 KB Output is correct