답안 #438832

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
438832 2021-06-28T17:21:05 Z KhoaHo Rabbit Carrot (LMIO19_triusis) C++11
0 / 100
1 ms 204 KB
///KhoaHo///
#include<bits/stdc++.h>
using namespace std;
///define-zone
#define task "test"
#define vec vector
#define priq priority_queue
#define pf push_front
#define pb push_back
#define popb pop_back
#define popf pop_front
#define SZ(a) a.begin(), a.end()
#define SZZ(a, begin, end) a + begin, a + begin + end
#define fi first
#define se second
#define N int(2e5) + 1

///typedef-zone
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
typedef double db;
typedef pair<int, int> ii;
typedef pair<long long, long long> pll;
typedef pair<int, ii> iii;

///code-mau
template<class val> inline val gcd(val a, val b){ return (a ? gcd(b%a, a): b);}

void init()
{
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
}

void fastio()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n, m, a[N];
vec<int> dp;
int f[N], g[N], maxx = 0;
int tknp(int l, int r, int x)
{
    int mid, ret = 0;
    while(l <= r)
    {
        mid = (l + r) >> 1;
        if(dp[g[mid]] <= x)
        {
            l = mid + 1;
            ret = mid;
        } else r = mid - 1;
    }
    return ret;
}
int main()
{
    ///init();
    fastio();
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if(a[i] - m*i <= 0) dp.pb(-a[i] + m*i);
    }
    f[0] = 1;
    g[1] = 0;
    if((int)dp.size() == 0)
    {
        cout << n;
        return 0;
    }
    for(int i = 1; i < (int)dp.size(); i++)
    {
        int k = tknp(1, f[maxx], dp[i]);
        f[i] = k + 1;
        g[k + 1] = i;
        if(f[maxx] < f[i]) maxx = i;
    }
    for(int i = 0; i < dp.size(); i++) cout << dp[i] << " \n"[i == dp.size() - 1];
    cout << n - f[maxx];
    return 0;
}



Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:83:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for(int i = 0; i < dp.size(); i++) cout << dp[i] << " \n"[i == dp.size() - 1];
      |                    ~~^~~~~~~~~~~
triusis.cpp:83:65: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for(int i = 0; i < dp.size(); i++) cout << dp[i] << " \n"[i == dp.size() - 1];
      |                                                               ~~^~~~~~~~~~~~~~~~
triusis.cpp: In function 'void init()':
triusis.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -