Submission #1111920

# Submission time Handle Problem Language Result Execution time Memory
1111920 2024-11-13T10:38:16 Z vjudge1 Global Warming (CEOI18_glo) C++17
0 / 100
53 ms 4748 KB
#include<bits/stdc++.h>
using namespace std;

const bool multiTest = false;
#define task "C"
#define fi first
#define se second
#define MASK(i) (1LL << (i))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define BIT(mask, i) ((mask) >> (i) & 1)

template<typename T1, typename T2> bool minimize(T1 &a, T2 b) {
	if (a > b) a = b; else return 0; return 1;
}
template<typename T1, typename T2> bool maximize(T1 &a, T2 b) {
	if (a < b) a = b; else return 0; return 1;
}

const int MAX = 200020;
int n, x;
int t[MAX];
int f[MAX];


void process(void) {
	cin >> n >> x;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i];
	}
	vector<int> dp;
	for (int i = 1; i <= n; ++i) {
		int pos = lower_bound(all(dp), t[i]) - dp.begin();
		if (dp.size() == pos) dp.push_back(t[i]);
		else dp[pos] = t[i];
		f[i] = pos + 1;
	}
	int res = *max_element(f + 1, f + 1 + n);
	dp.clear();
	for (int i = n; i >= 1; --i) {
		int pos = lower_bound(all(dp), x - t[i]) - dp.begin();
		maximize(res, pos + f[i]);
		cout << pos + f[i] << '\n';

		pos = lower_bound(all(dp), -t[i]) - dp.begin();
		if (dp.size() == pos) dp.push_back(-t[i]);
		else dp[pos] = -t[i];
	}
	cout << res;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r",  stdin);
		freopen(task".out", "w", stdout);
	}

	int nTest = 1; if (multiTest) cin >> nTest;
	while (nTest--) {
		process();
	}

	return 0;
}

Compilation message

glo.cpp: In function 'void process()':
glo.cpp:34:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |   if (dp.size() == pos) dp.push_back(t[i]);
      |       ~~~~~~~~~~^~~~~~
glo.cpp:46:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |   if (dp.size() == pos) dp.push_back(-t[i]);
      |       ~~~~~~~~~~^~~~~~
glo.cpp: In function 'int main()':
glo.cpp:55:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |   freopen(task".inp", "r",  stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp:56:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 4748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -