이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define ent "\n"
const int inf = (int)1e9 + 100;
const int maxn = 5e5 + 100;
const ll INF = (ll)1e18;
const int MOD = 1e9 + 7;
const int maxl = 62500;
const ll P = 31, T = 0;
int n, m;
ll a[maxn];
ll dp[maxn];
void test(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i];
a[i] -= 1ll * i * m;
}
int ans;
fill(dp + 1, dp + n + 1, INF);
for(int i = n; i >= 0; i--){
ans = 1;
for(int l = 1, r = n; l <= r;){
int mid = (l + r) >> 1;
if(dp[mid] > a[i]) r = mid - 1;
else l = mid + 1, ans = mid + 1;
}
dp[ans] = min(dp[ans], a[i]);
}
cout << n - ans + 1 << ent;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int t = 1;
if(T) cin >> t;
while(t--) test();
}
컴파일 시 표준 에러 (stderr) 메시지
triusis.cpp: In function 'void test()':
triusis.cpp:36:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
36 | cout << n - ans + 1 << ent;
| ~~^~~~~| # | 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... |