제출 #791381

#제출 시각아이디문제언어결과실행 시간메모리
791381MazhavilRabbit Carrot (LMIO19_triusis)C++17
100 / 100
30 ms4600 KiB
#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
template <typename T> T myMax(T x, T y)    //syntax: myMax<datatype>(x,y);
{
    return (x > y) ? x : y;
}
 
template<class T> using pq = priority_queue<T>;            // pq<int> pq;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, a) for (ll i=0; i<(a); i++)
#define repd(i,a) for (ll i = (a)-1; i >= 0; i--)
#define repi(i,a,b) for(ll i=(a); i<(b); i++)
#define repi_d(i,a,b) for(ll i=b-1; i>=a; i--)
#define trav(a,x) for (auto& a : x) //can be used everywhere
#define tr(a,x) for(auto a : x) //only for cout
#define deb(x) cout<<#x<< "=" <<x<<endl
#define deb2(x,y) cout<<#x<< "=" <<x<< "," <<#y<< "=" <<y<<endl
 
#define num(a,s) count(a.begin(),a.end(),s)     
#define nsort(a) sort(a.begin(),a.end())        //normal sort
#define rsort(a) sort(a.rbegin(),a.rend())  //reverse sort-descending order
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define PI 3.1415926535897932384626
#define max3(a,b,c) max(a,max(b,c))
const ll MOD = 1000000007;
const int MAXN = 1e6;
const char nl = '\n';
 const ll INF=1e18;
//BINARY EXPONENTIATION
/** Computes x^n modulo m in O(log p) time. */
ll binpow(ll a,ll b,ll m){
    ll res = 1;
    while (b){
        if (b&1) res = (res*a)%m;
        a = (a*a)%m;
        b>>=1;
    }
    return res;
}
 
//Multiplication of two long numbers mdulo M
ll binmul(ll n,ll m,ll M){
ll ans =0;
while(m){
    if(m&1){
        ans = (ans+n)%M;
    }
    n = (n+n)%M;
    m>>1;
}
return ans;
}
ll sq(ll n){
    ll a = sqrt(n);
    a++;
    if(a*a<=n){
        return a;
    }
    a--;
    if(a*a<=n){
        return a;
    }
    a--;
    return a;
}

int main() {
//setIO("");
    ios_base::sync_with_stdio(0); cin.tie(0);
 cout.tie(nullptr);

 int N,M;cin>>N>>M;
 vl b(N+1);
 repi(i,1,N+1){
    ll x;cin>>x;
    b[i]=1LL*M*i-x;
    //deb(i);
    //deb2(x,b[i]);
 }
 vector<ll>d(N+1,INF);
 d[0]=-INF;
 for(int i=1;i<N+1;i++){
    if(b[i]<0)continue;

    int ind=upper_bound(all(d),b[i])-d.begin();
    if(d[ind]>b[i] and d[ind-1]<=b[i]){
        d[ind]=b[i];
    }
 }
 int ans=0;
 for(int i=1;i<N+1;i++){
    if(d[i]<INF)ans=i;
 }
 ans=N-ans;
 cout<<ans<<endl;


return 0;
}

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

triusis.cpp: In function 'll binmul(ll, ll, ll)':
triusis.cpp:71:6: warning: statement has no effect [-Wunused-value]
   71 |     m>>1;
      |     ~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...