题目:click here

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
typedef long long ll;
using namespace std;
const int M = 1e5+5;
int n;
int a[M];
int b[M];
bool cmp( int a, int b ) { //从大到小排序
return a > b;
}
int main()
{
while( ~scanf("%d", &n ) ) {
memset( b, 0, sizeof(b) );
for( int i=0; i<n; i++ )
scanf("%d", a+i);
sort( a, a+n, cmp );
int cnt = 0;
for( int i=0; i<n-1; i++ ) {
if( a[i]-a[i+1] <= 1 ) {
b[cnt++] = a[i+1];
i++;
}
}
ll sum = 0;
for( int i=0; i<cnt-cnt%2; i+=2 ) {
sum += (ll)b[i]*(ll)b[i+1];
}
printf("%I64d\n", sum );
}
return 0;
}

CodeForces 525C Ilya and Sticks 贪心的更多相关文章

  1. Codeforces Round #297 (Div. 2)C. Ilya and Sticks 贪心

    Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  2. Codeforces Round #297 (Div. 2) 525C Ilya and Sticks(脑洞)

    C. Ilya and Sticks time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

    题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...

  4. C. Ilya and Sticks

    C. Ilya and Sticks time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. 1270: Wooden Sticks [贪心]

    点击打开链接 1270: Wooden Sticks [贪心] 时间限制: 1 Sec 内存限制: 128 MB 提交: 31 解决: 11 统计 题目描述 Lialosiu要制作木棍,给n根作为原料 ...

  6. codeforces Gym 100338E Numbers (贪心,实现)

    题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include< ...

  7. [Codeforces 1214A]Optimal Currency Exchange(贪心)

    [Codeforces 1214A]Optimal Currency Exchange(贪心) 题面 题面较长,略 分析 这个A题稍微有点思维难度,比赛的时候被孙了一下 贪心的思路是,我们换面值越小的 ...

  8. C - Ilya and Sticks(贪心)

    Problem description In the evening, after the contest Ilya was bored, and he really felt like maximi ...

  9. Codeforces 1119E Pavel and Triangles (贪心)

    Codeforces Global Round 2 题目链接: E. Pavel and Triangles Pavel has several sticks with lengths equal t ...

随机推荐

  1. jQuery学习之结构解析

    jQuery内核解析 1.jQuery整体的结构是一个匿名函数 (function( window, undefined ) {})(window); 2.jQuery就是一个很普通的函数,也是一个很 ...

  2. php内核--SAPI概述

  3. 快速注册Uber司机,兼职月入轻松过万

    Uber是世界领先的即时用车网络平台.当前部分中国城市,Uber司机只需每周完成70单,可获得7000元的激励制度回报司机,月收入近3万元.[加入条件]1. 车辆为本地牌照2. 车龄在5年以内3. 裸 ...

  4. p2.js物理引擎学习

    P2简介 P2是一款基于Javascript编写的HTML5 2D物理引擎,和Box2D.Nape等2D物理引擎一样,P2集成了各种复杂的物理公式和算法,可以帮助我们轻松的实现碰撞.反弹等物理现象的模 ...

  5. 通过自定义window来实现提示框效果

    #import <UIKit/UIKit.h>#import <Foundation/Foundation.h> @interface ZMStatuBarHud : NSOb ...

  6. Winter(bfs&&dfs)

    1084 - Winter   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Winter is ...

  7. poj2125Destroying The Graph(最小割+输出方案)

    题目请戳这里 题目大意:给一张有向图,现在要选择一些点,删掉图中的所有边.具体操作为:选择点i,可以选择删除从i出发的所有有向边或者进入i的所有有向边,分别有个代价ini和outi,求最小的代价删掉所 ...

  8. HA for openstack

    mysql ha instance ha openstack博客:http://blog.csdn.net/tantexian/article/list/2 使用eclipse远程调试openstac ...

  9. ASP.NET页面传值的几种方式

    页面传值是学习asp.net初期都会面临的一个问题,总的来说有页面传值. 存储对象传值.ajax.类.model.表单等!下面欧柏泰克和大家一起来看看asp.net页面传值方式一般有哪些?常用的较简单 ...

  10. HTML之表格与表单

    一.表格(table/tr/td) <table></table>表格 --不设高度 width:宽度.可以用像素或百分比表示. 常用960像素. border:边框,常用值为 ...