题目:链接
B cable cable cable:
观察得,答案为K*(M-K+1)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll M,K;
while(~scanf("%lld%lld",&M,&K))
printf("%lld\n",K*(M-K+1));
return 0;
}
D array array array:
若最长上升子序列的长度大于等于n-k,则是可以的,因为这里要求的不是严格的递增,
所以可以先将原数组处理成没有相同数字的数组,然后处理就好了。
代码:
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,k,dp[maxn],a[maxn];
vector<int>G[maxn];
bool check()
{
for(int i=0;i<maxn;i++) dp[i]=2e9;
for(int i=0;i<n;i++) *lower_bound(dp,dp+n,a[i])=a[i];
int len=lower_bound(dp,dp+n,2e9)-dp;
return n-len<=k;
}
int main()
{
int T