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. VS2012生成不依赖运行时不依赖MFC的MFC程序

    转载请注明来源:http://www.cnblogs.com/xuesongshu/ 1.新建MFC或者Win32工程,全部使用默认设置 2.设置工程属性,展开配置属性,转到:常规~MFC的使用,修改 ...

  2. 合理使用mysql中的load data infile导入数据

    基本语法: load data  [low_priority] [local] infile 'file_name txt' [replace | ignore]into table tbl_name ...

  3. 承接VR/AR内容应用定制需求

    业务范围: 1 承接VR/AR内容应用定制需求: 教育培训.建筑建设.旅游体验.课件教学系统.交通车辆仿真,模拟驾驶系统.游戏等.2 各类最新VR设备,例如GearVR.HTC vive.Oculus ...

  4. UITableView的编辑模式

    UITableView可以分普通模式和Editing模式两种,这里我们着重讨论Editing模式,Editing模式中又分三种操作:Insert.Delete. Reallocted.Insert和D ...

  5. Linux学习三部曲(之二)

    新建Linux分区以及文件系统 今天,我们来聊聊在linux上建立分区和文件系统.windows系统建立分区可以借助分区工具,那么在linux分区以及文件系统又该如何操作呢? 打开secureCRT, ...

  6. [WCF]IIS部署到新系统

    最近为以前的一个企业部署软件的时候,接触到WCF,通过博客园大佬的系列文章和一些书籍,基本了解了一些.简单说也算是SOA一种方式,提供某种服务,可以理解为一个类库,供其他项目使用,可以做到业务分离.但 ...

  7. [GeekBand] 面向对象的设计模式(C++)(2)

    本篇笔记紧接上篇,继续学习设计模式. 4. 对象创建类设计模式 通过对象创建模式绕开new,来避免对象创建(new)过程中所导致的紧耦合,从而支持对象创建的稳定.它是接口抽象之后的第一步工作. 4.1 ...

  8. LibCurl笔记四

    1,curl设置fiddler代理curl_easy_setopt(m_easyHandle, CURLOPT_PROXY, "127.0.0.1:8888"); 2,

  9. [ZZ+CH] Html5 canvas+js 时钟

    总之新Blog入驻以后,又开始老习惯,到处折腾自定义的空间,放些东西. 想起以前大一的时候做过一个Javascript的时间显示器,现在想做一个时钟,当然现在老奸巨猾,会先去看一看有前辈写过没. 前辈 ...

  10. javascript-对象的创建(一)

    <!DOCTYPE html> <%@ page language="java" contentType="text/html; charset=UTF ...