# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
639793 | a_aguilo | Global Warming (CEOI18_glo) | C++14 | 88 ms | 1840 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int n, x, HI;
void print(int v[]){
for(int i = 0; i < n; ++i) cout << " " << v[i];
cout << endl;
}
int binarySearch(int x, int arr[]){
int lo = 0, hi = HI;
int ans = 0;
while(hi >= lo){
int mid = lo + (hi-lo)/2;
if(arr[mid] <= x) {
lo = mid+1;
ans = mid;
}
else{
hi = mid-1;
}
}
return lo;
}
int main(){
cin >> n >> x;
int V[n];
int endWithLength[n];
for(int i = 0; i < n; ++i) cin >> V[i];
HI = 0;
memset(endWithLength, 0, sizeof(endWithLength));
endWithLength[0] = V[0];
for(int i = 1; i < n; ++i){
int pos = binarySearch((long long)V[i], endWithLength);
if(pos == HI){
if(V[i] >= endWithLength[pos]) pos++;
}
HI = max(HI, pos);
//cout << "i " << i << " || value " << V[i] << " || pos1 " << pos;
endWithLength[pos] = V[i];
//print(endWithLength);
}
cout << HI+1 << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |