日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【NOIP模拟题】Incr(dp)

發布時間:2025/3/15 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【NOIP模拟题】Incr(dp) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

太水的dp沒啥好說的。。

#include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> #include <set> #include <vector> #include <map> using namespace std; typedef long long ll; #define pii pair<int, int> #define mkpii make_pair<int, int> #define pdi pair<double, int> #define mkpdi make_pair<double, int> #define pli pair<ll, int> #define mkpli make_pair<ll, int> #define rep(i, n) for(int i=0; i<(n); ++i) #define for1(i,a,n) for(int i=(a);i<=(n);++i) #define for2(i,a,n) for(int i=(a);i<(n);++i) #define for3(i,a,n) for(int i=(a);i>=(n);--i) #define for4(i,a,n) for(int i=(a);i>(n);--i) #define CC(i,a) memset(i,a,sizeof(i)) #define read(a) a=getint() #define print(a) printf("%d", a) #define dbg(x) cout << (#x) << " = " << (x) << endl #define error(x) (!(x)?puts("error"):0) #define printarr2(a, b, c) for1(_, 1, b) { for1(__, 1, c) cout << a[_][__]; cout << endl; } #define printarr1(a, b) for1(_, 1, b) cout << a[_] << '\t'; cout << endl inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; } inline const int max(const int &a, const int &b) { return a>b?a:b; } inline const int min(const int &a, const int &b) { return a<b?a:b; }const int N=1e5+10; int n, g[N], f[N], a[N], ans;int main() {read(n);for1(i, 1, n) read(a[i]);CC(g, 0x7f);for1(i, 1, n) {int t=lower_bound(g+1, g+1+i, a[i])-g;f[i]=t;g[t]=a[i];ans=max(ans, t);}printf("%d", n-ans);return 0; }

  

?


?

?

?

【題目描述】

數列?A1,A2,...,AN,修改最少的數字,使得數列嚴格單調遞增。

?

【輸入格式】

第?1?行,1?個整數?N?

第?2?行,N?個整數?A1,A2,...,AN

【輸出格式】

1?個整數,表示最少修改的數字

?

【樣例輸入】

3

1?3?2

【樣例輸出】

1

【數據范圍】

對于?50%?的數據,N?≤?10^3?

對于?100%?的數據,1?≤?N?≤?10^5,1?≤?Ai?≤?10^9

總結

以上是生活随笔為你收集整理的【NOIP模拟题】Incr(dp)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。