# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1055379 | PotatoTheWarriorFRTT | Financial Report (JOI21_financial) | C++17 | 4077 ms | 2652 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;
long long MOD = 998244353;
typedef long long ll;
int log2(int x) {
int ln = -1;
while(x > 0) {
ln++;
x/=2;
}
return ln;
}
void solve() {
int n, d; cin >> n >> d;
ll a[n+1];
vector<ll> vals;
int ep = 1;
for(int i=0;i<n;i++) {
cin >> a[i];
}
int ans = 0;
vals.push_back(a[n-1]);
for(int i=n-2;i>=0;i--) {
if(a[i] >= vals[0]) {
vals[0] = a[i];
ep = 1;
}else if(a[i] < vals[ep-1]) {
if(ep == vals.size()) {
vals.push_back(a[i]);
}else{
vals[ep] = a[i];
}
ep++;
}else{
int r = 0;
int l = ep-1;
while(l-r > 0) {
int m = (l+r)/2;
if(a[i] < vals[m]) {
l = m;
}else if(a[i] >= vals[m]) {
r = m-1;
}
}
vals[l+1] = a[i];
}
// cout << ep << endl;
ans = max(ans, ep);
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
// cin >> t;
// while (t--)
solve();
char sdhfn;
}
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... |