C. MP3

爆ll ==

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define sc(x) scanf("%I64d",&x);
#define maxn 400005
vector<ll>v;
map<ll,ll>mp;
ll A[maxn];
ll len,K;
ll qp(ll n)
{
ll a=;
ll ans=;
while(n)
{
if(n&)
{
ans*=a;
}
if(a>=len||ans>=len){///防爆范围
ans=len;
return ans;
}
a*=a;
n>>=; }
return ans;
} ll sum[maxn];
void init()
{
for(int i=; i<=len; i++)
{
sum[i]+=sum[i-]+mp[v[i-]];
}
}
bool check(ll x)
{
ll n=len-K,t;
for(int i=; i<=n; i++)
{
t=;
t+=sum[i];
t+=sum[len]-sum[len-n+i];
if(t<=x)return true;
}
return false;
}
int main()
{
ll n;
ll I;
sc(n);
v.resize(n);
sc(I);
I*=;
for(ll i=; i<n; i++)
{
sc(v[i]);
mp[v[i]]++;
}
sort(v.begin(),v.end());
len=unique(v.begin(),v.end())-v.begin();
ll k=I/n;
K=qp(k);
init();
if(len<=K)
{
puts("");
return ;
}
ll l=,r=n,mid;
while(l+<=r)
{
mid=(l+r)>>;
if(check(mid))
{
r=mid;
}
else l=mid+;
}
if(check(l))
cout<<l<<'\n';
else cout<<r<<'\n'; }
/*
12 1
0 0 0 0 0 0 1 1 2 2 3 3
*/

576 C的更多相关文章

  1. leetcode 576. Out of Boundary Paths

    leetcode 576 题意大概就是在一个m*n的网格中,在坐标为[i,j]的网格上放一个物体,在规定时间N(t<=N)中,有多少种方法把物体移动出去.物体只能上下左右移动,一次移动一格,移动 ...

  2. 第十一周 Leetcode 576. Out of Boundary Paths (HARD) 计数dp

    Leetcode 576 给定一个二维平面, 一个球在初始位置(i,j)每次可以转移到上下左右的一格. 问在N次转移内,有多少种路径可以转移出边境. dp[i][j][k]为 在点(i,j) 已经走了 ...

  3. leetcode 576. Out of Boundary Paths 、688. Knight Probability in Chessboard

    576. Out of Boundary Paths 给你一个棋盘,并放一个东西在一个起始位置,上.下.左.右移动,移动n次,一共有多少种可能移出这个棋盘 https://www.cnblogs.co ...

  4. Java实现 LeetCode 576 出界的路径数(DFS || DP)

    576. 出界的路径数 给定一个 m × n 的网格和一个球.球的起始坐标为 (i,j) ,你可以将球移到相邻的单元格内,或者往上.下.左.右四个方向上移动使球穿过网格边界.但是,你最多可以移动 N ...

  5. 576. Out of Boundary Paths

    Problem statement: There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball ...

  6. 【转】Elastic日报 第576期 (2019-04-05)

    1.Elasticsearch性能测试实践http://t.cn/EiRzFiI2.监控Elasticsearch的插件推荐http://t.cn/EiRzFix3.支持机器数据的可扩展Elastic ...

  7. 【CodeForces】576 D. Flights for Regular Customers

    [题目]D. Flights for Regular Customers [题意]给定n个点m条边的有向图,每条边有di表示在经过该边前必须先经过di条边,边可重复经过,求1到n的最小经过边数.n,m ...

  8. 【CodeForces】576 B. Invariance of Tree

    [题目]B. Invariance of Tree [题意]给定n个数的置换,要求使n个点连成1棵树,满足u,v有边当且仅当a[u],a[v]有边,求一种方案或无解.n<=10^5. [算法]数 ...

  9. 【CodeForces】576 C. Points on Plane

    [题目]C. Points on Plane [题意]给定坐标系中n个点的坐标(范围[0,10^6]),求一种 [ 连边形成链后总长度<=2.5*10^9 ] 的方案.n<=10^6. [ ...

  10. Leetcode 576.出界的路劲数

    出界的路径数 给定一个 m × n 的网格和一个球.球的起始坐标为 (i,j) ,你可以将球移到相邻的单元格内,或者往上.下.左.右四个方向上移动使球穿过网格边界.但是,你最多可以移动 N 次.找出可 ...

随机推荐

  1. mysql多对多查询 原生写法

    准备工作,1.创建表 CREATE TABLE IF NOT EXISTS `users` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `name` VARCHAR ...

  2. laravel 设置自定义 Validator

    转自:https://learnku.com/docs/laravel/5.4/validation/1234#custom-validation-rules 自定义验证规则 Laravel 提供了许 ...

  3. window10 本地搭建SVN服务器

    window10本地搭建SVN服务器教程:https://www.cnblogs.com/warmlight/p/11075644.html 我按照这篇教程成功搭建SVN服务器. 有个比较坑的地方是w ...

  4. UVa 12169 Disgruntled Judge 紫书

    思路还是按照紫书,枚举a,得出b, 然后验证. 代码参考了LRJ的. #include <cstdio> #include <iostream> using namespace ...

  5. Hand on Machine Learning 第二章:端到端的机器学习

    1.import 模块 import os import tarfile from six.moves import urllib import pandas as pd pd.set_option( ...

  6. MyBatis Generator 生成的example 使用 and or 简单混合查询

    MyBatis Generator 生成的example 使用 and or 简单混合查询 参考博客:https://www.cnblogs.com/kangping/p/6001519.html 简 ...

  7. 远程访问其他主机的Mysql(Ubuntu)

    远程访问其他主机的Mysql 首先:被访问的电脑应该把防火墙关掉, sudo ufw disable 然后去etc/mysql sudo gedit my.cnf 将bind-address注解掉 由 ...

  8. Eigen的aligned_allocator

    今天看ORBSLAM2中的OptimizeEssentialGraph()函数时,对一句代码中的aligned_allocator不太清楚: vector<g2o::Sim3,Eigen::al ...

  9. 两台电脑使用ROS通讯

    一.ROS分布式多机通讯简介 ROS是一种分布式软件框架,节点之间通过松耦合的方式组合,在很多应用场景下,节点可以运行在不同的计算平台上,通过Topic,Service通信. 但是各个节点只能共同拥有 ...

  10. [Python3 填坑] 018 组装类的几个例子

    目录 1. print( 坑的信息 ) 2. 开始填坑 2.1 MetaClass 举例 2.2 type 举例 2.3 MetaClass 举例 1. print( 坑的信息 ) 挖坑时间:2019 ...