답안 #734447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734447 2023-05-02T12:10:56 Z farica Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 296 KB
#include <bits/stdc++.h>
#define div /
#define ll long long

#define fore(i, l, r) for(int i=int(l); i<int(r); i++)
#define sz(a) int((a).size())
#define mod 1000000007

using namespace std;

int main() {
    int n,m,cnt=0;
    cin >> n >> m;
    int h[n];
    vector<int>v;
    for(int i=0; i<n; ++i) {
        cin >> h[i];
    }
    for(int i=1; i<=n; ++i) {
        if((i*m)>=h[i-1]) v.push_back(i*m-h[i-1]);
    }
    vector<int>dp;
    for(int i=0; i<v.size(); ++i) {
        int pos=upper_bound(dp.begin(), dp.end(), v[i])-dp.begin();
        if(i==v.size()-1) {
            if(pos==(int)dp.size()) cout << n-(int)dp.size()+cnt-1 << endl;
            else cout << n-pos-1+cnt << endl;
            break;
        }
        if(pos==(int)dp.size()) dp.push_back(v[i]);
        else dp[pos]=v[i];
    }
    if(!v.size()) {
        cout << n << endl;
    }
    return 0;
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0; i<v.size(); ++i) {
      |                  ~^~~~~~~~~
triusis.cpp:25:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(i==v.size()-1) {
      |            ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -