Gym - 100203G Good elements 水+模拟
题意:good element的定义是a[i]在1~i-1中任取三个数(可以重复)的和能等于a[i]
思路:vis[x]标记一下任两个数的和,处理a[i]时枚举1~i-1判断vis[a[i] - a[j]]是否被标记
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define LL long long
#define eps 1e-8
#define INF 0x3f3f3f3f
#define MAXN 200005
using namespace std;
int a[];
bool vis[];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // OPEN_FILE
int n;
scanf("%d", &n);
for(int i = ; i <= n; i++){
scanf("%d", &a[i]);
}
int ans = ;
for(int i = ; i <= n; i++){
for(int j = ; j <= i - ; j++){
if(!vis[a[i] - a[j] + MAXN]) continue;
ans++;
break;
}
for(int j = ; j <= i; j++){
vis[a[i] + a[j] + MAXN] = true;
}
}
printf("%d\n", ans);
}
Gym - 100203G Good elements 水+模拟的更多相关文章
- Codeforces Gym 100203G Good elements 暴力乱搞
原题链接:http://codeforces.com/gym/100203/attachments/download/1702/statements.pdf 题解 考虑暴力的复杂度是O(n^3),所以 ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- CodeForces.71A Way Too Long Words (水模拟)
CodeForces71A. Way Too Long Words (水模拟) 题意分析 题怎么说你怎么做 没有坑点 代码总览 #include <iostream> #include & ...
- Codeforces Gym 100203G G - Good elements 标记暴力
G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- Codeforces Gym 100203G G - Good elements 暴力
G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- Gym 100851E Easy Problemset (水题,模拟)
题意:给定 n 个裁判,然后每个都一些题目,现在要从每一个按顺序去选出 k 个题,并且这 k 个要按不递减顺序,如果没有,就用50补充. 析:就按他说的来,直接模拟就好. 代码如下: #pragma ...
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A B C D 水 模拟 并查集 优先队列
A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforces Gym 100269B Ballot Analyzing Device 模拟题
Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...
- Codeforces Round #374 (Div. 2) A B C D 水 模拟 dp+dfs 优先队列
A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...
随机推荐
- vuex 基本入门和使用(三)-关于 mutation
vuex 基本入门和使用(三)-关于 mutation vuex 版本为^2.3.1,按照我自己的理解来整理vuex. 关于 mutation 这里应该很好理解. 更改 Vuex 的 store 中的 ...
- iview中单击行,使得checkbox状态的方法
直接贴代码,这是一组jquery全选,全不选,反选代码 <!DOCTYPE html> <html lang="en"> <head> < ...
- [转载]深入Java单例模式
在GoF的23种设计模式中,单例模式是比较简单的一种.然而,有时候越是简单的东西越容易出现问题.下面就单例设计模式详细的探讨一下. 所谓单例模式,简单来说,就是在整个应用中保证只有一个类的实例存在 ...
- LeetCode 232: Implement Queue using Stacks
Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...
- 9、包、访问控制、import、static、static代码块、final、抽象类、接口、instanceof、多态
1.包 三级命名:公司的尾缀(com).公司名字(baidu).业务(Sale) java.lang:默认包:String.Math,Object,System java.util:工具包 java. ...
- Compile OpenCASCADE7.3 with VS2008
Compile OpenCASCADE7.3 with VS2008 eryar@163.com 概述 在OpenCASCADE的源码文件夹中有个adm文件夹,里面提供了各个平台中编译源码的项目文件. ...
- angularjs作用域和函数调用
<!DOCTYPE HTML> <html ng-app> <head> <meta http-equiv="Content-Type" ...
- centos7 配置redis
文件上传 yum -y install lrzsz 安装redis部署前操作 同时下载redis-.tar.gz安装包 yum -y install gcc-c++ yum -y install tc ...
- python-网络-tcp
python-网络-tcp 标签(空格分隔): python TCP[client]-发送数据 from socket import * s = socket(AF_INET, SOCK_STREAM ...
- Intellij使用"easyexplore"
刚开始接触Intellij,里面有很多东西还不太会用,平时在eclipse里面用的很方便的easyexplore能帮助快速打开文件目录,Intellij中本身就有这样的功能,只是默认没有开启,需要我们 ...