CodeForces 131B Opposites Attract
来源:互联网 发布:五级网络啥时候上市 编辑:程序博客网 时间:2024/06/11 01:23
两重for循环妥妥超时
#include<stdio.h>#include<iostream>#include<math.h>#include<string.h>#include<iomanip>#include<stdlib.h>#include<ctype.h>#include<algorithm>#include<deque>#include<functional>#include<iterator>#include<vector>#include<list>#include<map>#include<queue>#include<set>#include<stack>#define CPY(A, B) memcpy(A, B, sizeof(A))typedef long long LL;typedef unsigned long long uLL;const int MOD = 1e9 + 7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const double EPS = 1e-9;const double OO = 1e20;const double PI = acos (-1.0);const int dx[] = {-1, 0, 1, 0};const int dy[] = {0, 1, 0, -1};using namespace std;const int maxn=1250;int a[15],b[15],z=0;int main() { int n,t; scanf ("%d",&n); for (int i=0; i<n; ++i) { scanf ("%d",&t); if (t>0) {++a[t];} else if (t<0) {++b[-t];} else { ++z; }//统计0的个数 }//two for loop will TLE uLL cnt=0; for (int i=0; i<11; ++i) {cnt+= (uLL) a[i]*b[i];}//匹配正负 cnt+= (uLL) z* (z-1) /2;//0 and other 0 cout<<cnt<<endl; return 0;}
0 0
- CodeForces 131B Opposites Attract
- CodeForces 131B Opposites Attract
- B. Opposites Attract
- Opposites Attract
- CodeForces 131B
- codeforces B
- codeforces B
- codeforces B
- codeforces B
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #131 (Div. 1) B. Numbers
- Attract and Keep Top Talent
- how to attract a girl
- CodeForces 626B CodeForces 626B【暴力】
- CodeForces 841B (B) 博弈
- codeforces 134B
- codeforces#98 b
- codeforces 105 div2 B
- NavigationBar的下方加上阴影
- 《PCL点云库学习&VS2010(X64)》Part 16 PCL1.72(VTK6.2.0)滤波例程(2)之双边滤波
- 使用Spring MVC拦截器实现日志记录
- 精简的后台程序代码——Insert
- JS处理时间
- CodeForces 131B Opposites Attract
- Makefile (二) 介绍
- 第二届移动互联网大会总结
- 源码-PL/SQL从入门到精通-第八章-记录与集合-Part 3
- 线性布局weight属性
- 【codevs 1225】八数码难题
- php入门基本概念
- 数据库连接池概述
- 关于裁剪CSV文件中的各类数据的代码