【链表】URAL 1579 Coat Transportation
来源:互联网 发布:单片机小车转弯 编辑:程序博客网 时间:2024/06/16 06:19
点击打开链接
题意:一个不递减的序列,一次能选取相差大于R的数列,要求最少次数选完所以的数。
并输出。
#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <set>#include <vector>#include <deque>#include <map>#define cler(arr, val) memset(arr, val, sizeof(arr))typedef long long LL;const int MAXN = 120000;const int MAXM = 140000;const int INF = 0x3f3f3f3f;const int mod = 1000000007;#define lson l,m,rt<<1#define rson m+1n 0;,r,rt<<1|1int head[MAXN],q[MAXN];struct node{ int next,a;}edge[MAXN];int main(){ int n,r,top=0; cler(edge,-1); cin>>n>>r>>edge[0].a; edge[0].next=-1; for(int i=1;i<n;i++) { cin>>edge[i].a; if(edge[i].a>edge[top].a+r) { edge[i].next=top; top++; } } printf("%d\n",n-top); for(int i=top;i<n;i++) { int k=0; for(int j=i;~j;j=edge[j].next) { q[k++]=j+1; } cout<<k; for(int j=k-1;j>=0;j--) printf(" %d",q[j]); printf("\n"); } return 0;}
0 0
- 【链表】URAL 1579 Coat Transportation
- canada goose coat-086811
- codeforces_667B. Coat of Anticubism
- Coat of Anticubism
- URAL 1992 CVS 链表
- URAL
- 【ural】
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- URAL
- app 上架
- [LeetCode]160.Intersection of Two Linked Lists
- EM算法
- three.js 源码注释(九十)extras/SceneUtils.js
- POJ 3311 Hie with the Pie(Floyd+状态压缩DP)
- 【链表】URAL 1579 Coat Transportation
- poj1013
- POJ 2451 Uyuw's Concert
- 实验室第一周工作周报—纪逸清
- linux学习之shell脚本 ------- shell函数
- Unity3D游戏开发之多线程及使用多线程
- Centeos安装配置nginx
- 动作识别之STIP(Space-Time Interest Point)(五)
- Majority Element