hdoj 6235 Permutation
来源:互联网 发布:helloworld的java程序 编辑:程序博客网 时间:2024/06/05 08:00
题目链接:Permutation
题目大意:要求你构造一个长度为n的1到n的排列使得
题目思路:直接构造相间隔的相差1的数组就好了
#include <map>#include <set>#include <cmath>#include <vector>#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>using namespace std;typedef long long ll;const ll maxn = 1e6+10;ll a[maxn],b[maxn];ll T,n,k,m;bool check(ll mid){ ll ans = 0,num = 0; ll l = 0,r = -1; while(r < n){ if(num < k){ if(a[r+1] >= mid) num++; r++; }else{ if(num == k) ans += (n-r); if(a[l] >= mid) num--; l++; if(ans >= m) return true; } } return false;}int main(){ scanf("%lld",&T); while(T--){ scanf("%lld%lld%lld",&n,&k,&m); for(ll i = 0;i < n;i++){ scanf("%lld",&a[i]); b[i] = a[i]; } sort(b,b+n); ll l = 0,r = n-1,mid,ans; while(l <= r){ mid = (l+r)>>1; if(check(b[mid])) ans = b[mid],l = mid+1; else r = mid-1; } printf("%lld\n",ans); } return 0;}
阅读全文
0 0
- hdoj 6235 Permutation
- hdoj 3664 Permutation Counting
- HDOJ 3664 Permutation Counting
- HDOJ 3664 Permutation Counting
- hdoj 2404 Permutation Recovery【水水】
- 【BestCoder】 HDOJ 5225 Tom and permutation
- hdoj 2404 Permutation Recovery 【水题(规律)】
- hdoj 2404 Permutation Recovery【基础题】
- HDOJ 2404 Permutation Recovery (逆序列)
- HDOJ 5753 Permutation Bo(排列组合)
- HDOJ 3664 Permutation Counting / UVALive 5092 DP
- hdu 6235 Permutation
- 【强连通分量】 HDOJ 4985 Little Pony and Permutation
- HDOJ题目4985Little Pony and Permutation(置换群)
- HDOJ 2404 Permutation Recovery(好题,学习了)
- Permutation
- Permutation
- permutation
- 机器学习-第四周作业——构建深度神经网络
- React学习笔记_ReactRedux应用使用AsyncAwait
- dubbo 常见错误
- CentOS 7下添加swap文件
- 关于C语言字母译码
- hdoj 6235 Permutation
- 安装python
- 官方解读双十一大促直播都看什么指标?
- 细谈那年初做自媒体经验分享
- vi基本操作命令
- Java学习——面向对象之多态
- Java 征途:行者的地图
- 并发编程
- 彻底明白RPC框架