Submission #582402

# Submission time Handle Problem Language Result Execution time Memory
582402 2022-06-23T17:31:29 Z Mr_Husanboy Global Warming (CEOI18_glo) C++14
55 / 100
2000 ms 10084 KB
// Muallif: Mansuraliyev Husanboy Murotali o'g'li  >> NamPS
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long 
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define vii vector<int>
#define vll vector<ll>
// 0-9 >> 48-57;    A-Z>>65-90   and   a-z>>97-122 respectively;


void solve(){
	int n; ll x; cin>>n>>x;
	ll a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	if(x==0){
	set<int> st;
	set<int>::iterator it;
	for(int i=0; i<n; i++) {
	    it = st.lower_bound(a[i]);
	    if (it != st.end()) st.erase(it);
	    st.insert(a[i]);
	}
	cout<<st.size()<<endl;
//	for(auto u:st) cout<<u<<" ";
	return;
	}
	if(x==1e9){
	vector<int> l,r;
	set<int> st;
	set<int>::iterator it;
	for(int i=0; i<n; i++) {
	    it = st.lower_bound(a[i]);
	    if (it != st.end()) st.erase(it);
	    st.insert(a[i]);
	    l.push_back(st.size());
	}
	st.clear(); int ans=0;
	reverse(a,a+n);
	for(int i=0; i<n; i++) {
	    it = st.lower_bound(-a[i]);
	    if (it != st.end()) st.erase(it);
	    st.insert(-a[i]);
	    r.push_back(st.size());
	}
	reverse(all(r));
	r.push_back(0);
	for(int i=0;i<n;i++){
		ans=max(l[i]+r[i+1],ans);
	}
	cout<<ans<<"\n";return;
	}
	int ans=0;
	for(int j=0;j<n;j++){
		for(int i=0;i<j;i++){
			a[i]-=x;
		}
		set<int> st;
		set<int>::iterator it;
		st.clear();
		for(int i=0; i<n; i++) {
		    it = st.lower_bound(a[i]);
		    if (it != st.end()) st.erase(it);
		    st.insert(a[i]);
		}
		ans=max(ans,int(st.size()));
		//cout<<j<<": "<<st.size()<<"\n";
		for(int i=0;i<j;i++) a[i]+=x;
	}
	cout<<ans<<"\n";
}
 
int main(){
	ios;
//	int t; cin>>t; while(t--)
	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 116 ms 304 KB Output is correct
20 Correct 99 ms 308 KB Output is correct
21 Correct 102 ms 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 106 ms 340 KB Output is correct
24 Correct 80 ms 340 KB Output is correct
25 Correct 76 ms 356 KB Output is correct
26 Correct 75 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 1884 KB Output is correct
2 Correct 61 ms 1876 KB Output is correct
3 Correct 51 ms 1876 KB Output is correct
4 Correct 52 ms 1908 KB Output is correct
5 Correct 60 ms 6468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2070 ms 720 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2264 KB Output is correct
2 Correct 46 ms 3156 KB Output is correct
3 Correct 94 ms 6064 KB Output is correct
4 Correct 108 ms 9484 KB Output is correct
5 Correct 51 ms 4792 KB Output is correct
6 Correct 81 ms 9188 KB Output is correct
7 Correct 87 ms 10084 KB Output is correct
8 Correct 36 ms 3104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 116 ms 304 KB Output is correct
20 Correct 99 ms 308 KB Output is correct
21 Correct 102 ms 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 106 ms 340 KB Output is correct
24 Correct 80 ms 340 KB Output is correct
25 Correct 76 ms 356 KB Output is correct
26 Correct 75 ms 340 KB Output is correct
27 Correct 66 ms 1884 KB Output is correct
28 Correct 61 ms 1876 KB Output is correct
29 Correct 51 ms 1876 KB Output is correct
30 Correct 52 ms 1908 KB Output is correct
31 Correct 60 ms 6468 KB Output is correct
32 Execution timed out 2070 ms 720 KB Time limit exceeded
33 Halted 0 ms 0 KB -