답안 #540525

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
540525 2022-03-20T16:33:55 Z juankipedia Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 476 KB
# include <bits/stdc++.h>
using namespace std;
/*************************************************************************************/
# define endl "\n"
# define io_boost std::ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
typedef unsigned long long int ulli;
typedef long long int lli;
/*************************************JUANKIPEDIA*************************************/
const int MAXN = 200005;

lli a[MAXN], J;

int len, n;
int lis[MAXN];
    vector<lli> s;
int LIS(){
    len = 0;
    vector<int> l;
    int lis_len[MAXN], pos;
    for(int i = 0; i < n; i++){
        int j = upper_bound(l.begin(), l.end(), s[i]) - l.begin();
        if(j == l.size()) l.push_back(s[i]);
        else l[j] = s[i];
        lis_len[i] = j + 1;
        if(lis_len[i] > len){
            len = lis_len[i];
            pos = i;
        }
    }
    return len;
}

int main(){
    io_boost;
    cin >> n >> J;
    for(int i = 0; i < n; i++) cin >> a[i];

    for(int i = 0; i < n; i++)
        if((i + 1) * J >= a[i]) s.push_back((i + 1) * J - a[i]);
    cout << n - LIS() << endl;
    return 0;
}

Compilation message

triusis.cpp: In function 'int LIS()':
triusis.cpp:22:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if(j == l.size()) l.push_back(s[i]);
      |            ~~^~~~~~~~~~~
triusis.cpp:19:24: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
   19 |     int lis_len[MAXN], pos;
      |                        ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 476 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 476 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 476 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 476 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -