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输入/输出系统中的其他流学习笔记

    一.字节数组流 字节数组流类能够操作内存中的字节数组,它的数据是一个字节数组.字节数组流类本身适配器设计模式,它把字节数组类型转为流类型使得程序能够对字节数组进行读写操作. 1.ByteArrayIn ...

  2. 本招聘信息2014年长期有效!杭州派尔科技高薪诚聘android开发(10K-20K),web前端开发(8K-15K),IOS开发(15K-25K)

    杭州派尔科技有限公司发展至今,离不开员工的无私奉献和辛勤耕耘,在努力创造更好成绩的同时,公司也不忘回馈每一位员工的努力与付出.1.全面的绩效考核机制,让发展空间近在眼前!公司力争让每一位员工都了解自己 ...

  3. 移动Web单行文字垂直居中的问题

    单行文字垂直居中的方式你可能可以脱口而出,height和line-height设置为同样就行了,或者设置相同的padding-top和padding-bottom值. 上图是Chrome浏览器下的效果 ...

  4. zz Release memory in Linux (Unused or Cached)

    In computer science, Memory Leakage occurs when a computer software or program consumes required mem ...

  5. 官方 Material Design App

    [转]MaterialDesignCenter 发表回复 转: https://github.com/lightSky/MaterialDesignCenter MaterialDesignCente ...

  6. C#,PHP对应加密函数

    require_once "JunDes.php"; $jDes=new JunDes(); echo $jDes->encode('98765'); //echo $jDe ...

  7. javascript学习笔记(5

    1.string Array Date Math 内置对象的属性和方法? 答案: ①String 字符串 属性 :length  获取字符串长度 方法: indexOf()  从左到右检索子字符串在原 ...

  8. php学习日志(2)-php变量

    变量是用于存储数据的容器,与代数相似,可以给变量赋予某个确定的值(例如:$x=3)或者是赋予其它的变量(例如:$x=$y+$z).变量的定义主要有以下规则: 变量以$开始,后面跟着变量的名称: 变量名 ...

  9. 前端encodeURIComponent 和后端http_build_query配合

    解决特殊字符不能转义 1.  function fixedEncodeURIComponent (str) {  return encodeURIComponent(str).replace(/[!' ...

  10. DataSnap Demo:TFDConnection、最大连接数、客户端回叫功能、多线程模拟、压力测试等

    一.限制最大连接数,并验证来访者用户身份: procedure TServerContainer1.DSServer1Connect( DSConnectEventObject: TDSConnect ...