답안 #369343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369343 2021-02-21T11:11:35 Z BeanZ Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 364 KB
// I_Love_LPL
// 1
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 2e5 + 5;
long long mod = 1e9 + 7;
const int lim = 700;
const int lg = 19;
const long double eps = 1e-6;
ll a[N], b[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("tests.inp", "r")){
        freopen("test.inp", "r", stdin);
        freopen("test.ans", "w", stdout);
    }
    ll n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] -= i * m;
    }
    ll sz = 0;
    for (int i = 1; i <= n; i++){
        ll l = 1, h = sz;
        while (l <= h){
            ll mid = (l + h) >> 1;
            if (b[mid] >= a[i]) l = mid + 1;
            else h = mid - 1;
        }
        if (l > sz){
            sz++;
        }
        b[l] = a[i];
    }
    cout << n - sz;
}
/*
Ans:

Out:
*/

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         freopen("test.ans", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -