답안 #873628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
873628 2023-11-15T12:07:28 Z MisterReaper Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
140 ms 84648 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

//#define ONLINE_JUDGE
void solve() {
    int n, m;
    cin >> n >> m;

    vector <int> vec(n);
    for(int &i : vec)
        cin >> i;

    vector <int> v;
    for(int i = 0; i < n; i++) {
        if(vec[i] <= m * (i +1))
            v.emplace_back(m * (i +1) - vec[i]);
    }

    vector <int> dp;
    for(int &i : v) {
        auto it = upper_bound(dp.begin(), dp.end(), i);
        if(it == dp.end())
            dp.emplace_back(i);
        else 
            *it = i;
    }

    cout << n - int(dp.size());
    
    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen(".in", "r", stdin);
        freopen(".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}

Compilation message

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