Codeforces Round #204 (Div. 2): B
很简单的一个题;
只需要将他们排一下序,然后判断一下就可以了!
代码:
#include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std; int n,x;
int a[maxn][],cot;
struct node
{
int v,id;
bool operator<(node const &t)const
{
if(v==t.v)return id<t.id;
return v<t.v;
}
} no[maxn]; int main()
{
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%d",&x);
no[i].v=x;
no[i].id=i;
}
sort(no+,no+n+);
for(int i=; i<=n;)
{
int t=no[i].v;
if(no[i+].v!=t)
{
a[cot][]=no[i].v;
a[cot][]=;
cot++;
i++;
}
else
{
int d=no[i+].id-no[i].id;
while()
{
i++;
if(no[i+].v!=t)
{
a[cot][]=t;
a[cot][]=d;
cot++;
i++;
break;
}
if(no[i+].id-no[i].id!=d)
{
while()
{
i++;
if(no[i+].v!=no[i].v)
{
i++;
break;
}
}
break;
}
}
}
}
printf("%d\n",cot);
for(int i=;i<cot;i++)
printf("%d %d\n",a[i][],a[i][]);
return ;
}
Codeforces Round #204 (Div. 2): B的更多相关文章
- CF&&CC百套计划3 Codeforces Round #204 (Div. 1) A. Jeff and Rounding
http://codeforces.com/problemset/problem/351/A 题意: 2*n个数,选n个数上取整,n个数下取整 最小化 abs(取整之后数的和-原来数的和) 先使所有的 ...
- Codeforces Round #204 (Div. 2)->C. Jeff and Rounding
C. Jeff and Rounding time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CF&&CC百套计划3 Codeforces Round #204 (Div. 1) E. Jeff and Permutation
http://codeforces.com/contest/351/problem/E 题意: 给出一些数,可以改变任意数的正负,使序列的逆序对数量最少 因为可以任意加负号,所以可以先把所有数看作正数 ...
- CF&&CC百套计划3 Codeforces Round #204 (Div. 1) B. Jeff and Furik
http://codeforces.com/contest/351/problem/B 题意: 给出一个n的排列 第一个人任选两个相邻数交换位置 第二个人有一半的概率交换相邻的第一个数>第二个数 ...
- CF&&CC百套计划3 Codeforces Round #204 (Div. 1) D. Jeff and Removing Periods
http://codeforces.com/problemset/problem/351/D 题意: n个数的一个序列,m个操作 给出操作区间[l,r], 首先可以删除下标为等差数列且数值相等的一些数 ...
- Codeforces Round #204 (Div. 2) A.Jeff and Digits
因为数字只含有5或0,如果要被90整除的话必须含有0,否则输出-1 如果含有0的话,就只需考虑组合的数字之和是9的倍数,只需要看最大的5的个数能否被9整数 #include <iostream& ...
- Codeforces Round #204 (Div. 2)->D. Jeff and Furik
D. Jeff and Furik time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #204 (Div. 2)->B. Jeff and Periods
B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #204 (Div. 2) C
写了一记忆化 TLE了 把double换成long long就过了 double 这么耗时间啊 #include <iostream> #include<cstdio> #i ...
随机推荐
- Android注解支持(Support Annotations)
注解支持(Support Annotations) Android support library从19.1版本开始引入了一个新的注解库,它包含很多有用的元注解,你能用它们修饰你的代码,帮助你发现bu ...
- IT技能栈
C++.JAVA.Objective-C 基本数据类型,集合类如字符串数组字典,自定义数据对象 内存布局,编译运行期的变化 语言特性 输入输出流,文件流,序列化 多线程,并发控制,线程池,锁 网络编程 ...
- c# 值传递 引用传递
以前一直误以为引用类型,在作为参数传递时,都是引用传递(类似于值传递中的ref),也就是说,把引用类型的变量作为参数传递给方法,在方法中修改该参数,会改变这个变量的值, 后来通过一些事例发现,上面的认 ...
- centos 6.3 编译安装 nginx +mysql + php
这篇文章是对另一篇文章的整理,作为记录收藏 1,配置防火墙,开启80端口.3306端口 配置iptables,开启80端口.3306端口 vi /etc/sysconfig/iptables -A I ...
- mysql case when then else end 用法
select case when 判断条件 then 输出结果 else 输出结果 end from table
- [功能帮助类] JsHelper--Javascript操作帮助类 (转载)
点击下载 JsHelper.rar 这个类是关于加密,解密的操作,文件的一些高级操作1.Javascript弹出信息,并跳转指定页面. 2.Javascript弹出信息,并返回历史页面3.Javasc ...
- Android eclipse - aapt.exe has stopped working.
今天在修改Android的布局文件的时候,发现每保存一次,就提示: aapt.exe has stopped working(appt.exe已停止工作).很是郁闷,当时Android控制台已经提示错 ...
- C# 读取txt文本内容写入到excel
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- IOS多线程知识总结/队列概念/GCD/串行/并行/同步/异步
进程:正在进行中的程序被称为进程,负责程序运行的内存分配;每一个进程都有自己独立的虚拟内存空间: 线程:线程是进程中一个独立的执行路径(控制单元);一个进程中至少包含一条线程,即主线程. 队列:dis ...
- jQuery AJAX load() 方法
jQuery load() 方法 jQuery load() 方法是简单但强大的 AJAX 方法. load() 方法从服务器加载数据,并把返回的数据放入被选元素中. 语法: $(selector). ...