답안 #500726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500726 2021-12-31T23:14:15 Z pooty Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1877 ms 262144 KB
#define REP(i, n) for(int i = 0; i < n; i ++)
#define REPL(i,m, n) for(int i = m; i < n; i ++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define SORT(arr) sort(arr.begin(), arr.end())
#define LSOne(S) ((S)&-(S))
#define M_PI 3.1415926535897932384
#define INF 999999999
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;cin>>n;
	vii arr;
	int prev = -1;
	REP(i, n) {
		int x,y;cin>>x>>y;
		if (x== prev) {
			arr.back().second = max(arr.back().second, y);
		} else {
			arr.push_back({x,y});
		}
		prev = x;
	}
	int sze = arr.size();
	bool covered[sze];
	memset(covered, 0, sizeof(covered));
	int prevOffset = -1;
	REP(i, sze) {
		auto [x,y] = arr[i];
		int cur = x+y;
		if (cur <= prevOffset) {
			covered[i] = true;
		}
		prevOffset = max(cur, prevOffset);
	}
	prevOffset = -1;
	for (int i = sze-1; i >=0; i--) {
		auto [x,y] = arr[i];
		int dx = 1e9 - x;
		int cur = dx + y;
		if (cur <= prevOffset) {
			covered[i]= true;
		}
		prevOffset = max(cur, prevOffset);
	}
	int tot = sze;
	REP(i, sze) {
		if (covered[i]) tot--;
	}cout<<tot;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1528 ms 229152 KB Output is correct
2 Correct 1541 ms 229460 KB Output is correct
3 Correct 1546 ms 229408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 264 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 264 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 37 ms 5552 KB Output is correct
15 Correct 40 ms 5420 KB Output is correct
16 Correct 36 ms 4736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1541 ms 212924 KB Output is correct
2 Correct 1541 ms 212868 KB Output is correct
3 Correct 1474 ms 212964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1528 ms 229152 KB Output is correct
2 Correct 1541 ms 229460 KB Output is correct
3 Correct 1546 ms 229408 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 0 ms 264 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 37 ms 5552 KB Output is correct
18 Correct 40 ms 5420 KB Output is correct
19 Correct 36 ms 4736 KB Output is correct
20 Correct 1541 ms 212924 KB Output is correct
21 Correct 1541 ms 212868 KB Output is correct
22 Correct 1474 ms 212964 KB Output is correct
23 Correct 1877 ms 262144 KB Output is correct
24 Correct 1862 ms 262144 KB Output is correct
25 Correct 1712 ms 250276 KB Output is correct