C. Jury Marks 思维
这个题目虽然是只有1600,但是还是挺思维的。
有点难想。
应该可以比较快的推出的是这个肯定和前缀和有关,
x x+a1 x+a1+a2 x+a1+a2+a3...
x+sum=b
所以我们可以通过b来枚举每一个x,如果这个x可以满足找到m个b,那就说明这个x是合理的。
但是要注意的是,这个sum的去重,为什么要去重呢,因为如果不去虫,就是找到两个相同的 因为x=b-sum
所以可以只要枚举b[1]即可,因为对于每一个b,其中一个确定之后,剩下的b的位置也固定了。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<iomanip>
#define INF 99999999
using namespace std;
const int maxn = 2e6 + ;
typedef long long ll;
int a[maxn];
ll sum[maxn];
map<ll, int>mp; int main()
{
int n, m;
scanf("%d%d", &n, &m);
for(int i=;i<=n;i++)
{
scanf("%lld", &sum[i]);
sum[i] += sum[i - ];
mp[sum[i]] = ;
}
for (int i = ; i <= m; i++) scanf("%d", &a[i]);
sort(sum + , sum + + n);
int len = unique(sum + , sum + + n) - sum - ;
int ans = ;
for(int i=;i<=len;i++)
{
int cnt = , num = a[] - sum[i];
for(int j=;j<=m;j++)
{
if (mp[a[j] - num]) cnt++;
}
if (cnt >= m) ans++;
}
printf("%d\n", ans);
return ;
}
C. Jury Marks 思维的更多相关文章
- C. Jury Marks 思维题
http://codeforces.com/contest/831/problem/C 做的时候想不到,来了个暴力. 对于每个b[i],枚举每一个a[i],就有1个可能的情况. 然后用vector存起 ...
- C. Jury Marks
C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces831C Jury Marks
C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- #424 Div2 Problem C Jury Marks (二分 && 暴力 && std::unique && 思维)
题目链接 :http://codeforces.com/contest/831/problem/C 题意 :选手有一个初始积分,接下来有k个裁判为他加分或减分(时间顺序给出),然后告诉你n(1< ...
- CF831C Jury Marks
思路: 关键在于“插入”一个得分之后,其他所有得分也随之确定了. 实现: #include <iostream> #include <cstdio> #include < ...
- 【Codeforces Round #424 (Div. 2) C】Jury Marks
[Link]:http://codeforces.com/contest/831/problem/C [Description] 有一个人参加一个比赛; 他一开始有一个初始分数x; 有k个评委要依次对 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)
http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- CF-831C
C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
随机推荐
- Python 文件拼接
# -*- coding:utf-8 -*- import re import csv file = open('make_setup.cfg', 'w+') with open("tyb. ...
- 新版本Xcode 6的视图调试详解
开发者会经常遇到视图或者Auto Layout约束中存在bug的情况,并且这种bug很难通过代码发现,所以开发者很有必要熟知如何进行简单高效的视图调试,而Xcode 6的发布使得视图调试变得前所未有的 ...
- AJ学IOS 之UIDynamic重力、弹性碰撞吸附等现象
AJ分享,必须精品 一:效果 重力和碰撞 吸附现象 二:简介 什么是UIDynamic UIDynamic是从iOS 7开始引入的一种新技术,隶属于UIKit框架 可以认为是一种物理引擎,能模拟和仿真 ...
- PDF阅读器
1.SumatraPDF 非常小巧,打开很轻快 2.PDF Reader by Xodo window商店中可以找到,很好用 3. PDFXChange Editor这是我迄今为止见过的最好的PDF编 ...
- 最短路径变形 POJ 2253
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sit ...
- vue2.x学习笔记(十)
接着前面的内容:https://www.cnblogs.com/yanggb/p/12584237.html. 事件处理 使用javascript当然少不了事件处理,即使是vue也不会例外. 监听事件 ...
- [护网杯2018] easy_laravel
前言 题目环境 buuoj 上的复现,和原版的题目不是完全一样.原题使用的是 nginx + mysql 而 buuoj 上的是 apache + sqlite composer 这是在 PHP5.3 ...
- 尝试用python开发一款图片压缩工具1:尝试 pillow库
开发目的 我经常使用图片.公众号文章发文也好,还是生活中要使用素材.图片是一种比文字更加直观的载体.但是图片更加占用带宽,很多软件都对图片有大小限制.图片太大也会影响加载速度.我试过几款图片压缩工具, ...
- Spring Cloud Gateway+Nacos,yml+properties两种配置文件方式搭建网关服务
写在前面 网关的作用不在此赘述,举个最常用的例子,我们搭建了微服务,前端调用各服务接口时,由于各服务接口不一样,如果让前端同事分别调用,前端同事会疯的.而网关就可以解决这个问题,网关屏蔽了各业务服务的 ...
- testlink配置修改
1. Read/write permissions报错 问题: Checking if /var/testlink/logs/ directory exists [S] </B< ...