제출 #768828

#제출 시각아이디문제언어결과실행 시간메모리
768828Doncho_BonbonchoRabbit Carrot (LMIO19_triusis)C++14
100 / 100
21 ms5176 KiB
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
 
#define endl "\n"
 
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
 
#ifndef LOCAL
#define cerr if(false) cerr
#define endl "\n"
#endif
 
template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T, typename B = decay<decltype(*begin(declval<T>()))>, typename enable_if<!is_same<T, string>::value>::type* = nullptr>
ostream& operator <<(ostream &os, const T &c) {
    bool f = false;
    os << "(";
    for(const auto &x : c) {
        if(f) os << ", "; f = true;
        os << x;
    }
    return os << ")";
}
 
 
#define out(x) #x << "=" << x << " "
struct debug {
    debug(const string &msg) { cerr << "LINE " << msg <<  ": "; }
    ~debug() { cerr << endl; }
 
    template<class T>
    debug& operator <<(const T x) {
        cerr << x;
        return *this;
    }
};
#define dbg debug(to_string(__LINE__))
 
typedef long long ll;
const ll mod = 1e9 + 7;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

const int MAX_N = 2e5 + 42;
int a[MAX_N];
std::vector<ll> v;
signed main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif
	
	int n, m;
	std::cin>>n>>m;

	for( int i=1 ; i<=n ; i++ ) std::cin>>a[i];

	for( int i=1 ; i<=n ; i++ ){
		if( m*i < a[i] ) continue;
		ll curr = m*i - a[i];
		int ind = std::upper_bound( v.begin(), v.end(), curr ) - v.begin();
		if( ind == v.size() ) v.push_back( curr );
		else v[ind] = curr;
		cerr<<v<<endl;
	}

	std::cout<<n - v.size()<<endl;
 
    return 0;
}

// To the OGs, I'm thankin' you now
// Was watchin' you when you was pavin' the ground
// I copied your cadence, I mirrored your style
// I studied the greats, I'm the greatest right now

컴파일 시 표준 에러 (stderr) 메시지

triusis.cpp: In function 'std::ostream& operator<<(std::ostream&, const T&)':
triusis.cpp:24:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   24 |         if(f) os << ", "; f = true;
      |         ^~
triusis.cpp:24:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   24 |         if(f) os << ", "; f = true;
      |                           ^
triusis.cpp: In function 'int main()':
triusis.cpp:66:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   if( ind == v.size() ) v.push_back( curr );
      |       ~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...