이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma warning(disable : 6031)
#define USACO freopen("exercise.in", "r", stdin); freopen("exercise.out", "w+", stdout)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
using namespace std;
ll binpow(ll a, ll x, ll m) {
ll ans = 1, md = a % m;
while (x != 0) {
if (x % 2 == 1) ans = (ans * md) % m;
md = (md * md) % m;
x >>= 1;
}
return ans;
}
ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
return a * b / gcd(a, b);
}
/*
*/
int h[200000], d[200001];
void solve() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> h[i];
h[i] -= i * m;
}
d[0] = INT32_MIN;
for (int i = 1; i <= n; i++) d[i] = INT32_MAX;
for (int i = 0; i < n; i++) {
int l = 0, r = n;
while (l < r) {
int mid = l + (r - l + 1) / 2;
if (d[mid] <= h[i]) l = mid;
else r = mid - 1;
}
if (l != n) d[l + 1] = min(d[l + 1], h[i]);
}
for (int i = n; i >= 1; i--) {
if (d[i] != INT32_MAX) {
cout << i << "\n";
return;
}
}
}
int main() {
//USACO;
fastIO;
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
triusis.cpp:2: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
2 | #pragma warning(disable : 4996)
|
triusis.cpp:3: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
3 | #pragma warning(disable : 6031)
|
# | 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... |