답안 #917195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917195 2024-01-27T12:21:44 Z sano Global Warming (CEOI18_glo) C++14
100 / 100
51 ms 5636 KB
#include <iostream>
#include <string>
#include <string.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include<map>
#include <stack>
#include <unordered_map>
#include <set>
#include <math.h> 
#include <cstdlib> 
#include <time.h> 
#define ll long long
#define For(i, n) for(int i = 0; i < n; ++i)
#define ffor(i, a, n) for(int i = a; i < n; ++i)
#define pb push_back
#define vec vector 
#define ff first
#define ss second
#define pairs pair<sui, sui>
#define NEK 1000000000
#define mod 1000000007
#define vel 1000
using namespace std;
typedef unsigned short int sui;

vec<int> lds(vec<int> a, int k) {
	vec<int> odp(a.size(), 0);
	vec<int> dp;
	for (int i = a.size() - 1; i > -1; i--) {
		int x1 = lower_bound(dp.begin(), dp.end(), (a[i] - k) * (-1)) - dp.begin();
		odp[i] = x1 + 1;
		auto x2 = lower_bound(dp.begin(), dp.end(), a[i] * (-1));
		if (x2 == dp.end()) {
			dp.push_back(a[i] * (-1));
		}
		else {
			*x2 = a[i] * (-1);
		}
	}
	return odp;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ifstream cin("cowjog.in");
	//ofstream cout("cowjog.out");
	int n, x;
	cin >> n >> x;
	vec<int> a;
	For(i, n) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	vec<int> bc = lds(a, x);
	vec<int> dp;
	int maxi = 0;
	For(i, n) {
		a[i] -= x;
		int x2 = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
		if (x2 == dp.size()) {
			dp.push_back(a[i]);
		}
		else {
			dp[x2] = a[i];
		}
		maxi = max(maxi, x2 + bc[i]);
	}
	cout << maxi << '\n';
	return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:66:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   if (x2 == dp.size()) {
      |       ~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 0 ms 600 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 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 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 0 ms 600 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 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 348 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 0 ms 456 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 0 ms 600 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 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 348 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 0 ms 456 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 720 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 456 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 4816 KB Output is correct
2 Correct 45 ms 4820 KB Output is correct
3 Correct 46 ms 4816 KB Output is correct
4 Correct 45 ms 4812 KB Output is correct
5 Correct 22 ms 4816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1504 KB Output is correct
2 Correct 11 ms 1504 KB Output is correct
3 Correct 12 ms 1676 KB Output is correct
4 Correct 6 ms 1504 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 6 ms 1504 KB Output is correct
7 Correct 8 ms 1504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2644 KB Output is correct
2 Correct 18 ms 2520 KB Output is correct
3 Correct 38 ms 4656 KB Output is correct
4 Correct 24 ms 4832 KB Output is correct
5 Correct 13 ms 2520 KB Output is correct
6 Correct 19 ms 4564 KB Output is correct
7 Correct 23 ms 5328 KB Output is correct
8 Correct 16 ms 2524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 0 ms 600 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 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 348 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 0 ms 456 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 720 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 456 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 51 ms 4816 KB Output is correct
28 Correct 45 ms 4820 KB Output is correct
29 Correct 46 ms 4816 KB Output is correct
30 Correct 45 ms 4812 KB Output is correct
31 Correct 22 ms 4816 KB Output is correct
32 Correct 11 ms 1504 KB Output is correct
33 Correct 11 ms 1504 KB Output is correct
34 Correct 12 ms 1676 KB Output is correct
35 Correct 6 ms 1504 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 6 ms 1504 KB Output is correct
38 Correct 8 ms 1504 KB Output is correct
39 Correct 20 ms 2644 KB Output is correct
40 Correct 18 ms 2520 KB Output is correct
41 Correct 38 ms 4656 KB Output is correct
42 Correct 24 ms 4832 KB Output is correct
43 Correct 13 ms 2520 KB Output is correct
44 Correct 19 ms 4564 KB Output is correct
45 Correct 23 ms 5328 KB Output is correct
46 Correct 16 ms 2524 KB Output is correct
47 Correct 22 ms 2524 KB Output is correct
48 Correct 23 ms 2744 KB Output is correct
49 Correct 47 ms 4864 KB Output is correct
50 Correct 22 ms 4820 KB Output is correct
51 Correct 24 ms 3800 KB Output is correct
52 Correct 25 ms 5076 KB Output is correct
53 Correct 21 ms 4728 KB Output is correct
54 Correct 25 ms 5636 KB Output is correct
55 Correct 35 ms 4816 KB Output is correct