| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1284767 | KhanhDang | Global Warming (CEOI18_glo) | C++17 | 40 ms | 2808 KiB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define Unique(v) sort(all(v)); (v).erase(unique(all(v)), (v).end());
const int N = 2e5 + 5;
int n, x;
int a[2][N];
int f[2][N];
int res[2];
int Find(int t, int x) {
int l = 1, r = res[t], j = 0;
while (l <= r) {
int m = (l + r) >> 1;
if (x > f[t][m]) {
j = m;
l = m + 1;
} else r = m - 1;
}
return j;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define task "bseq"
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
if (fopen("task.inp", "r")) {
freopen("task.inp", "r", stdin);
freopen("task.out", "w", stdout);
}
cin>>n>>x;
for (int i = 1; i <= n; i++) {
cin>>a[0][i];
a[1][i] = a[0][i] + x;
}
f[0][1] = a[0][1]; res[0] = 1;
f[1][1] = a[1][1]; res[1] = 1;
for (int i = 2; i <= n; i++) {
int j = Find(0, a[0][i]);
int k = max(Find(0, a[1][i]),
Find(1, a[1][i]));
if (j == res[0]) f[0][++res[0]] = a[0][i];
else if (a[0][i] < f[0][j + 1])
f[0][j + 1] = a[0][i];
if (k == res[1]) f[1][++res[1]] = a[1][i];
else if (a[1][i] < f[1][k + 1])
f[1][k + 1] = a[1][i];
}
cout<<max(res[0], res[1]);
cerr<<setprecision(3)<<fixed<<"Time elapsed: "<< 1.0 * clock() / CLOCKS_PER_SEC <<"s\n";
}
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... | ||||
