A. Be Positive 【 Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) 】
be div round Codeforces Positive Alex
2023-06-13 09:17:22 时间
Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) |
---|
题意:给你 n 个数,找个 d 让这个 n 个数除以 d 之后大于零的数至少是 n / 2 个。
&:分类一下,输出 1 或者 -1 或者 0 就可以了。
#include<bits/stdc++.h>
using namespace std;
int a[200];
int main()
{
int n;
int sum = 0;
int num = 0;
int cnt = 0;
scanf("%d", &n);
for(int i = 0; i < n; i ++)
{
scanf("%d", &a[i]);
if(a[i] == 0) sum ++;
if(a[i] < 0) num ++;
if(a[i] > 0) cnt ++;
}
int m;
if(n % 2 != 0) m = n / 2 + 1;
else m = n / 2;
if(sum > m ) printf("0\n");
else {
if(sum == m){
if(n % 2 != 0) printf("0\n");
else {
if(num == 0)printf("1\n");
else if(cnt == 0)printf("-1\n");
else printf("0\n");
}
}
else {
if(num >= m) printf("-1\n");
else if(cnt >= m) printf("1\n");
else printf("0\n");
}
}
return 0;
}
相关文章
- ORA-01107: database must be mounted for media recovery ORACLE 报错 故障修复 远程处理
- ORA-23369: value of “string” argument cannot be null ORACLE 报错 故障修复 远程处理
- ORA-25149: Columns of UROWID type may not be indexed ORACLE 报错 故障修复 远程处理
- ORA-25202: invalid value NULL, string should be non-NULL ORACLE 报错 故障修复 远程处理
- ORA-39181: Only partial table data may be exported due to fine grain access control on string ORACLE 报错 故障修复 远程处理
- ORA-48318: ADR Relation [string] of version=string cannot be supported ORACLE 报错 故障修复 远程处理
- ORA-54035: keyword HIDDEN cannot be specified here ORACLE 报错 故障修复 远程处理
- ORA-01541: system tablespace cannot be brought offline; shut down if necessary ORACLE 报错 故障修复 远程处理
- ORA-02097: parameter cannot be modified because specified value is invalid ORACLE 报错 故障修复 远程处理
- ORA-02761: File number to be canceled is negative. ORACLE 报错 故障修复 远程处理
- ORA-10631: SHRINK clause should not be specified for this object ORACLE 报错 故障修复 远程处理
- ORA-14310: VALUES LESS THAN or AT clause cannot be used with List partitioned tables ORACLE 报错 故障修复 远程处理
- ORA-14624: DEFAULT subpartition must be last subpartition specified ORACLE 报错 故障修复 远程处理
- ORA-15455: FORCE option cannot be used when specifying ALL volumes ORACLE 报错 故障修复 远程处理
- ORA-19023: The first argument to UPDATEXML operator has to be an XMLTYPE ORACLE 报错 故障修复 远程处理
- nginx -t “nginx: [warn] only the last index in “index” directive should be absolute in 6 “的问题解决详解程序员
- java.lang.ClassCastException:org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcesso详解编程语言
- be探索Oracle中QBE的强大功能(oracle中的q)