7.28 EOI
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N = 2e5 + 50;
const int M = 1e5 + 50;
const int Mod = 1e9 + 7;
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int t, n, k;
int w[N], v[N];
signed main()
{
freopen("ball.in", "r", stdin);
freopen("ball.out", "w", stdout);
t = read();
while (t--)
{
n = read(), k = read();
for (int i = 1; i <= n; ++i)
w[i] = read();
sort(w + 1, w + n + 1);
for (int i = 1; i <= k; ++i)
v[i] = read() - 1;
sort(v + 1, v + k + 1);
ll res = 0;
int r = n;
for (int i = 1; i <= k; ++i)
{
if (!v[i])
res += w[r] * 2;
else
res += w[r];
r--;
}
for (int i = 1; i <= k; ++i)
{
if (!v[i])
continue;
res += w[r - v[i] + 1];
r -= v[i];
}
printf("%lld\n", res);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define int long long
const int N = 1e2 + 50;
const int M = 1e3 + 50;
const int Mod = 1e9 + 7;
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int t, n, m;
int a[N], b[N];
int f[M];
// int q[M];
signed main()
{
freopen("group.in", "r", stdin);
freopen("group.out", "w", stdout);
t = read();
while (t--)
{
n = read(), m = read();
for (int i = 1; i <= n; ++i)
a[i] = read();
for (int i = 1; i <= n; ++i)
b[i] = read();
memset(f, 0, sizeof(f));
f[0] = 1;
for (int i = 1; i <= n; ++i)
{
for (int r = m; r > m - a[i]; --r)
{
for (int j = r; j >= a[i]; j -= a[i])
{
for (int k = 1; k <= b[i]; ++k)
{
if (j >= k * a[i])
f[j] = (f[j] + f[j - k * a[i]]) % Mod;
else
break;
}
}
}
}
int res = 0;
for (int i = 1; i <= m; ++i)
{
res = (res + f[i]) % Mod;
}
printf("%lld\n", res);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N = 3e2 + 50;
const int M = 1e5 + 50;
const int Mod = 1e9 + 7;
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int t, n;
int v[N];
int a[N][N], f[N][N];
int main()
{
freopen("match.in", "r", stdin);
freopen("match.out", "w", stdout);
t = read();
while (t--)
{
n = read();
for (int i = 1; i <= n; ++i)
v[i] = read();
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= n; ++j)
{
a[i][j] = read();
}
}
memset(f, 0, sizeof(f));
for (int i = 0; i <= n; ++i)
f[i][i] = i;
for (int len = 1; len <= n; ++len)
{
for (int l = 1; l <= n - len + 1; ++l)
{
int r = l + len - 1;
for (int k = l; k < r; ++k)
{
if (a[f[l][k]][f[k + 1][r]])
{
if (v[f[l][r]] < v[f[l][k]])
{
f[l][r] = f[l][k];
}
}
else
{
if (v[f[l][r]] < v[f[k + 1][r]])
{
f[l][r] = f[k + 1][r];
}
}
}
}
}
printf("%d\n", v[f[1][n]]);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N = 2e5 + 50;
const int M = 1e5 + 50;
const int Mod = 1e9 + 7;
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
int t, n, k, MX;
int a[N];
priority_queue<int, vector<int>, greater<int>> s, CLEAR;
bool check(int x)
{
s = CLEAR;
for (int i = 1; i < k; ++i)
s.push(a[i]);
for (int i = k; i <= n; ++i)
{
s.push(a[i]);
if (x >= s.top())
x += s.top();
else
return false;
s.pop();
if (x >= MX)
return true;
}
for (int i = 1; i < k; ++i)
{
if (x >= s.top())
x += s.top();
else
return false;
s.pop();
if (x >= MX)
return true;
}
return true;
}
signed main()
{
freopen("monster.in", "r", stdin);
freopen("monster.out", "w", stdout);
t = read();
while (t--)
{
n = read(), k = read();
MX = 0;
for (int i = 1; i <= n; ++i)
a[i] = read(), MX = max(MX, a[i]);
int l = 0, r = 1e9, ans = Mod;
while (l < r)
{
int mid = l + r >> 1;
if (check(mid))
{
ans = min(ans, mid);
r = mid;
}
else
{
l = mid + 1;
}
}
printf("%d\n", ans);
}
return 0;
}
7.28 EOI的更多相关文章
- Linux Kernel 2.6.28 以上有BUG,系统运行第208.5天down机
简介: 业务服务器有一台服务器出现意外down机,服务器ping 不通.无法登陆,本想通过公司KVM系统登陆系统重启解决,登陆KVM后发现系统屏幕打印大量的内核错误,KVM无法使用.无法发送重启服务器 ...
- 28个你必须知道的HTML5的新特性,技巧以及技术
崭新新的页面布局 传统的: HTML5: 1. 新的Doctype 尽管使用<!DOCTYPE html>,即使浏览器不懂这句话也会按照标准模式去渲染 2. Figure元素 用<f ...
- CSharpGL(28)得到高精度可定制字形贴图的极简方法
CSharpGL(28)得到高精度可定制字形贴图的极简方法 回顾 以前我用SharpFont实现了解析TTF文件从而获取字形贴图的功能,并最终实现了用OpenGL渲染文字. 使用SharpFont,美 ...
- 来,一起让我们越来越懒,面向CSS、JS未来编程。(9.28已更新)
2016.10.29更新 本文存在大量的错误,仅供参考. 不知不觉在前端领域马上一个年头就要过去了,然而再看看自己的代码,果然够烂,那么为什么代码一直没有用面向对象的思维去写CSS呢?首先有两点:一点 ...
- MySQL报错:Got error 28 from storage engine
今天碰到数据库出错: Got error 28 from storage engine 查了一下,数据库文件所在的盘应该没事,应该是数据库用的临时目录空间不够 问题原因: 磁盘临时空间不够导致. 解决 ...
- [.net 面向对象程序设计进阶] (28) 结束语——告别2015
[.net 面向对象程序设计进阶] (28) 结束语——告别2015 <.net面向对象程序设计进阶>这一系列文章写了太长的时间了,大概有半年没写,在年底又一口气写了好几篇.在整个过程中目 ...
- 背水一战 Windows 10 (28) - 控件(文本类): TextBox, PasswordBox
[源码下载] 背水一战 Windows 10 (28) - 控件(文本类): TextBox, PasswordBox 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) T ...
- 10月28日PHP基础知识测试题
本试题共40道选择题,10道判断题,考试时间1个半小时 一:选择题(单项选择,每题2分): 1. LAMP具体结构不包含下面哪种(A) A:Windows系统 B:Apache服务器 C:MySQL数 ...
- CentOS6.3编译安装Nginx1.4.7 + MySQL5.5.25a + PHP5.3.28
[准备工作] #在编译安装lnmp之前,首先先卸载已存在的rpm包. rpm -e httpd rpm -e mysql rpm -e php yum -y remove httpd yum -y r ...
- 记 Mac Pro 系统升级后,编译安装 PHP-5.6.28 / PHP-7.0 报错修复过程
买 Mac Pro 的时候,系统为 OS X 10.11.5,编译 PHP-5.6.21 的时候,也遇到一些坑,安装过程记录如下: Mac Pro 编译安装 PHP 5.6.21 及 问题汇总 后来, ...
随机推荐
- React基本引入和JSX语法
1.1 React介绍 1.1.1. 官网 英文官网:https://reactjs.org/ 中文官网: https://react.docschina.org/ 1.1.2. 介绍描述 用于动态构 ...
- AI作画本地搭建
前言 Novel AI (简称NAI)是一个线上的深度学习小说续写平台,而 NAI Diffusion 是 NAI 在2022年10月3日推出的基于 Stable Diffusion 算法的自动生成二 ...
- Django容易被遗忘却无比重要的框架默认文件介绍及使用方法
在Python Web开发领域,Django框架的地位犹如璀璨的明星,其全面.高效和安全的特性使其在全球范围内广受欢迎.本文将全面解析Django框架的默认文件,并深入探讨每个文件及其组成的意义和用途 ...
- 项目完成小结:使用Blazor和gRPC开发大模型客户端
前言 先介绍下这个项目. 最近我一直在探索大语言模型,根据不同场景训练了好几个模型,为了让用户测试使用,需要开发前端. 这时候,用 Gradio 搭建的前端是不太够的,虽说 GitHub 上也有一堆开 ...
- 为什么Python是数据科学家的首选语言
这篇文章全面探讨了Python作为数据科学领域首选语言的原因.从Python的历史.特性,到在数据科学中的应用实例,再到与其他数据科学语言的比较,以及在实际企业中的应用,我们深入剖析了Python的优 ...
- linux 脚本:iptables-secure.sh
#!/bin/bash # 2022.2.28 by dewan # secutiry configuration. usage () { echo "$0 start # setup se ...
- 长连接:chatgpt流式响应背后的逻辑
一.前言: 提起长连接,我们并不陌生,最常见的长连接非websocket莫属了.即使没有在项目中实际用过,至少也应该有所接触.长连接指在一次网络通信中,客户端与服务器之间建立一条持久的连接,可以在多次 ...
- 压缩CSS样式与js样式
方法一: 使用插件:JS & CSS Minifier (Minify) 使用方法: 效果: 或者按下F1,输入命令:Minify:Document
- 一条命令突破Windows限制,暂定更新时间至3000天
在系统界面上最长也就只能延期 35 天,而且 35 天以后一定要更新了才能继续暂停.不过,我找到了一段能延长暂停时间的代码 reg add "HKEY_LOCAL_MACHINE\SOFTW ...
- 2023-08-02:给定一棵树,一共有n个点, 每个点上没有值,请把1~n这些数字,不重复的分配到二叉树上, 做到 : 奇数层节点的值总和 与 偶数层节点的值总和 相差不超过1。 返回奇数层节点分配
2023-08-02:给定一棵树,一共有n个点, 每个点上没有值,请把1~n这些数字,不重复的分配到二叉树上, 做到 : 奇数层节点的值总和 与 偶数层节点的值总和 相差不超过1. 返回奇数层节点分配 ...