Submission #940000

#TimeUsernameProblemLanguageResultExecution timeMemory
940000vjudge1Global Warming (CEOI18_glo)C++17
28 / 100
2053 ms6872 KiB
#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 tree<int, null_type, less<int>, rb_tree_tag,
    tree_order_statistics_node_update> ordered_set;
#define int long long
#define ff first
#define ss second
const int INF = 1e9 + 7;
const int N = 1e6 + 1;
 
int LIS(vector<int> a){
	 
	set<int> dp;
	for(int i = 0;i < (int)a.size(); i++){		
		int x = a[i];
		if(dp.lower_bound(x) != dp.end()) dp.erase(dp.lower_bound(x));
		dp.insert(x);
	}
	return (int)dp.size();
} 
 
main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
	int x; cin >> x;
	vector<int> a(n);
	for(int i = 0;i < n; i++){
		cin >> a[i];
	}
	vector<int> A = a;
	int ans = LIS(a);
	for(int i = 0;i < n; i++){
		a[i]+= -x;
		ans = max(ans, LIS(a));
	}
	a = A;
	for(int i = n-1; i >= 0; i--){
		a[i]+= x;
		ans = max(ans, LIS(a));
	}
	cout << ans;
    return 0;
}

Compilation message (stderr)

glo.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...