http://codeforces.com/problemset/problem/300/A

题意 :给你n个数字,让你分成3组,第一组各个数之积要小于0,第二组要大于0,第三组要等于0,符合要求的答案可能会有很多种,输出其中一种。

思路 :表示一开始以为要把n个数分成3组,第一组里的数都大于0这样子,所以一直卡在这儿。。。。因为这个题也相当于special judge了吧,所以要找一个最不容易出错的输出,把n个数排序,最小的肯定是负的(题目保证至少有一个正确答案),所以直接把它分在第一组就行,然后如果然后最大的数分在第二组,当然了,如果最大的数也不大于0,这时候就要把第二个第三个放在一起,这样乘积就是正数了,而剩下的因为包含一个0,所以就直接弄一组去就行了

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std ;
int main()
{
int n ;
while(scanf("%d",&n)!=EOF)
{
int a[] ;
for(int i = ; i < n ; i++)
scanf("%d",&a[i]) ;
sort(a,a+n) ;
printf("1 %d\n",a[]) ;
if(a[n-] > )
{
printf("1 %d\n",a[n-]);
printf("%d",n-) ;
for(int i = ; i < n- ; i++)
printf(" %d",a[i]) ;
}
else
{
printf("2 %d %d\n",a[],a[]) ;
printf("%d",n-) ;
for(int i = ; i < n ; i++)
printf(" %d",a[i]) ;
}
printf("\n") ;
}
return ;
}

CodeForces 300A Array的更多相关文章

  1. Codeforces 797E - Array Queries

    E. Array Queries 题目链接:http://codeforces.com/problemset/problem/797/E time limit per test 2 seconds m ...

  2. Codeforces 1108E2 Array and Segments (Hard version) 差分, 暴力

    Codeforces 1108E2 E2. Array and Segments (Hard version) Description: The only difference between eas ...

  3. 网络流(最大流):CodeForces 499E Array and Operations

    You have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m goo ...

  4. Codeforces 1108E2 Array and Segments (Hard version)(差分+思维)

    题目链接:Array and Segments (Hard version) 题意:给定一个长度为n的序列,m个区间,从m个区间内选择一些区间内的数都减一,使得整个序列的最大值减最小值最大. 题解:利 ...

  5. Codeforces 623B Array GCD

    Array GCD 最后的序列里肯定有a[1], a[1]-1, a[1]+1, a[n], a[n]-1, a[n]+1中的一个,枚举质因子, dp去check #include<bits/s ...

  6. CodeForces 57C Array 组合计数+逆元

    题目链接: http://codeforces.com/problemset/problem/57/C 题意: 给你一个数n,表示有n个数的序列,每个数范围为[1,n],叫你求所有非降和非升序列的个数 ...

  7. codeforces A. Array 解题报告

    题目链接:http://codeforces.com/problemset/problem/300/A 题目意思:给出n个数,将它们分成三批:1.所有数相乘的结果 < 0    2.所有数相乘的 ...

  8. CodeForces - 1175D Array Splitting(数组划分+后缀和+贪心)

    You are given an array a1,a2,…,ana1,a2,…,an and an integer kk. You are asked to divide this array in ...

  9. codeforces#1108E2. Array and Segments (线段树+扫描线)

    题目链接: http://codeforces.com/contest/1108/problem/E2 题意: 给出$n$个数和$m$个操作 每个操作是下标为$l$到$r$的数减一 选出某些操作,使$ ...

随机推荐

  1. JAVA中RSS解析器(rome.jar和jdom.jar)范例

    1.需要 jdom.jar 和 rome.jar 这两个包.2.创建一个项目,web.xml的内容如下: 代码如下 复制代码 <?xml version="1.0" enco ...

  2. SQL中CONVERT()函数用法详解

    SQL中CONVERT函数格式: CONVERT(data_type,expression[,style]) 参数说明: expression 是任何有效的 Microsoft® SQL Server ...

  3. 【译】 Node.js v0.12的新特性 -- Cluster模式采用Round-Robin负载均衡

    原文:https://strongloop.com/strongblog/whats-new-in-node-js-v0-12-cluster-round-robin-load-balancing 本 ...

  4. OCI的结果输出

    绑定变量,把结果以列的方式输出到每一字段输出到一个数组里

  5. 线程模式HS/HA和L/F的区别, HS/HA的实现原理图

    线程池模式一般分为两种:L/F领导者与跟随者模式.HS/HA半同步/半异步模式. HS/HA 半同步/ 半异步模式 :分为三层,同步层.队列层.异步层,又称为生产者消费者模式,主线程处理I/O事件并解 ...

  6. JQuery 判断某个属性是否存在 hasAttr

    $(".fengye a").each(function () { if (typeof($(this).attr("href")) != "unde ...

  7. php下删除一篇文章生成的多个静态页面

    php自定义函数之删除一篇文章生成的多个静态页面,可能有多页的文章,都是需要考虑到的. 复制代码代码如下: //– 删除一篇文章生成的多个静态页面  //– 生成的文章名为 5.html 5_2.ht ...

  8. centos install(160112更新)

    centos安装之后: 更新 yum update 新增用户: useradd myuser passwd myuser 添加sudo: usermod -a -G wheel myuser //vi ...

  9. Iso8601 日期格式

    unit Iso8601Unit; interface type TIso8601 = class(TObject) public class function DateTimeFromIso8601 ...

  10. uniquery 配合 mssql 自带存储过程实现分页

    --使用系统存储过程实现的通用分页存储过程 -- 此过程原作者,应该是:邹健老前辈 CREATE PROC sp_PageView @sql ntext, --要执行的sql语句 , --要显示的页码 ...