답안 #397043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397043 2021-05-01T08:45:34 Z jsannemo Global Warming (CEOI18_glo) C++14
10 / 100
54 ms 2104 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

	int N, D;
	cin >> N >> D;
	typedef pair<int, int> p;
	vector<p> res1, res2;
	rep(i,0,N) {
		int x;
		cin >> x;
		auto it1 = lower_bound(all(res1), p{x, 0});
		if (it1 == res1.end()) res1.emplace_back(), it1 = res1.end()-1;
		*it1 = {x, i};

		auto it2 = lower_bound(all(res2), p{x, 0});
		if (it2 == res2.end()) res2.emplace_back(), it2 = res2.end()-1;
		*it2 = {x, i};
		
		int it3 = lower_bound(all(res1), p{x+D, 0}) - res1.begin();
		if (it3 == sz(res2)) res2.emplace_back(x, i);
		res2[it3] = min(res2[it3], {x, i});
	}
	cout << max(sz(res1), sz(res2)) << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 324 KB Output is correct
2 Correct 54 ms 336 KB Output is correct
3 Correct 53 ms 332 KB Output is correct
4 Correct 54 ms 336 KB Output is correct
5 Correct 38 ms 2104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 332 KB Output is correct
2 Correct 28 ms 340 KB Output is correct
3 Incorrect 50 ms 328 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -