A:显然构造一组只包含1和2面值的数据即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
} signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
int n=read();
cout<<n*2-1<<' '<<2<<endl;
cout<<1<<' '<<2;
return 0;
//NOTICE LONG LONG!!!!!
}

  B:显然两种pizza的分配应尽可能贴近第二种更优和第一种更优的人数关系。于是在这个边界附近±1暴力枚举一下,然后贪心非常显然。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,m;
ll t=0,ans=0;
struct data
{
int x,y,z;
bool operator <(const data&a) const
{
return y-x>a.y-a.x;
}
}a[N];
bool cmp(const data&x,const data&y)
{
return abs(x.y-x.x)>abs(y.y-y.x);
}
void check(ll k)
{
if (k<0||k>t) return;
ll x=1ll*k*m,y=(t-k)*m,s=0;
for (int i=1;i<=n;i++)
if (a[i].y>a[i].x)
{
if (a[i].z<=x) s+=1ll*a[i].y*a[i].z,x-=a[i].z;
else if (x) s+=1ll*a[i].y*x,s+=1ll*a[i].x*(a[i].z-x),y-=a[i].z-x,x=0;
else s+=1ll*a[i].x*a[i].z,y-=a[i].z;
}
else
{
if (a[i].z<=y) s+=1ll*a[i].x*a[i].z,y-=a[i].z;
else if (y) s+=1ll*a[i].x*y,s+=1ll*a[i].y*(a[i].z-y),x-=a[i].z-y,y=0;
else s+=1ll*a[i].y*a[i].z,x-=a[i].z;
}
ans=max(ans,s);
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
n=read(),m=read();
for (int i=1;i<=n;i++) t+=a[i].z=read(),a[i].x=read(),a[i].y=read();
sort(a+1,a+n+1);
t=(t-1)/m+1;
ll x=0;for (int i=1;i<=n;i++) if (a[i].y>a[i].x) x+=a[i].z;else break;
sort(a+1,a+n+1,cmp);
for (ll i=x/m-2;i<=x/m+2;i++) check(i);
sort(a+1,a+n+1);
x=0;for (int i=1;i<=n;i++) if (a[i].y>=a[i].x) x+=a[i].z;else break;
sort(a+1,a+n+1,cmp);
for (ll i=x/m-2;i<=x/m+2;i++) check(i);
cout<<ans;
return 0;
//NOTICE LONG LONG!!!!!
}

  D:注意到在某一天卖出再买进对答案是没有影响的。于是维护一个小根堆,每次取出堆顶与当前天价格比较,若能赚钱则计入答案并将堆顶弹出,相当于在堆顶那天买进然后在当前天卖出,然后将当前天价格入堆。我们还需要支持一个反悔操作,即更换买进天的匹配对象,容易发现把当前天价格再入一次堆就可以了。大约是在模拟费用流。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define ll long long
#define N 300010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,a[N];
ll ans=0;
priority_queue<int,vector<int>,greater<int> > q;
signed main()
{
#ifndef ONLINE_JUDGE
freopen("d.in","r",stdin);
freopen("d.out","w",stdout);
#endif
n=read();
for (int i=1;i<=n;i++) a[i]=read();
for (int i=1;i<=n;i++)
{
if (!q.empty()&&q.top()<a[i])
{
ans+=a[i]-q.top();
int x=q.top();q.pop();
q.push(a[i]);
}
q.push(a[i]);
}
cout<<ans;
return 0;
//NOTICE LONG LONG!!!!!
}

  C:期望考虑倒推,但难以计算重置带来的影响。于是考虑先固定住重置的作用,即二分答案,这样重置之后就相当于可以用等于答案的时间直接通关。然后就可以dp了,即设f[i][j]为i~n关要用至多j时间通关的话最少要花多久。最后得到f[1][m],判断其和二分出的答案的大小,若比其大说明一开始就得重置,这显然说明二分出来的答案小了;反之亦然。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 110
#define inf ((double)100000000000)
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
int x=0,f=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
int n,m,a[N],b[N],p[N];
double f[N][N*N];
signed main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
n=read(),m=read();
for (int i=1;i<=n;i++) a[i]=read(),b[i]=read(),p[i]=read();
double l=0,r=inf,ans;
for (int _=1;_<=100;_++)
{
double mid=(l+r)/2;
for (int i=n;i>=1;i--)
for (int j=0;j<=m;j++)
{
f[i][j]=0.01*((a[i]+(j>=a[i]?f[i+1][j-a[i]]:mid))*p[i]+(b[i]+(j>=b[i]?f[i+1][j-b[i]]:mid))*(100-p[i]));
if (i>1) f[i][j]=min(f[i][j],mid);
}
if (f[1][m]>mid) ans=mid,l=mid;else r=mid;
}
printf("%.11f",ans);
return 0;
//NOTICE LONG LONG!!!!!
}

  

Codeforces Round #437 Div. 1的更多相关文章

  1. Codeforces Round #437 (Div. 2)[A、B、C、E]

    Codeforces Round #437 (Div. 2) codeforces 867 A. Between the Offices(水) 题意:已知白天所在地(晚上可能坐飞机飞往异地),问是否从 ...

  2. Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2)

    Problem A Between the Offices 水题,水一水. #include<bits/stdc++.h> using namespace std; int n; ]; i ...

  3. Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2) E

    题意:减前面的数,加后面的数,保证最后不剩下数,加减次数要相同: 题解:emmmmm,看出是个贪心,先对价值排序,相同就对下标排序,规律是每次找第一个,然后从后往前找没有使用过的下表比他大的第一个,相 ...

  4. 【Codeforces Round #437 (Div. 2) A】Between the Offices

    [链接]h在这里写链接 [题意] 在这里写题意 [题解] 在这里写题解 [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc++.h> using n ...

  5. 【Codeforces Round #437 (Div. 2) B】Save the problem!

    [链接]h在这里写链接 [题意]     给你一个金额N,和硬币的类型总数M;     (完全背包),然后问你组成N的方案数.     使得,用这些硬币组成价值为N的金额的方案数为A;     现在A ...

  6. 【Codeforces Round #437 (Div. 2) C】 Ordering Pizza

    [链接]h在这里写链接 [题意]     给你参赛者的数量以及一个整数S表示每块披萨的片数.     每个参数者有3个参数,si,ai,bi;     表示第i个参赛者它要吃的披萨的片数,以及吃一片第 ...

  7. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

随机推荐

  1. 性能调优2:CPU

    关系型数据库严重依赖底层的硬件资源,CPU是服务器的大脑,当CPU开销很高时,内存和硬盘系统都会产生不必需要的压力.CPU的性能问题,直观来看,就是任务管理器中看到的CPU利用率始终处于100%,而侦 ...

  2. WebClient, HttpClient, HttpWebRequest ,RestSharp之间的区别与抉择

    NETCore提供了三种不同类型用于生产的REST API: HttpWebRequest;WebClient;HttpClient,开源社区创建了另一个名为RestSharp的库.如此多的http库 ...

  3. 9宫拼图小游戏(WPF MVVM实现)

    昨天逛论坛,看到一个哥们用WPF做了一个9宫的拼图游戏,发现初学WPF的人都很容易犯一个错误(我也犯过):把WPF当WINFORM用!所以想写一个比较符合WPF风格的版本,于是就抽工作的空余时间做了一 ...

  4. 华为交换机-SNMP配置

    1.1     SNMP基础配置 <switch>system-view 进入交换机的配置模式 [switch]snmp-agent 使能snmp服务 [switch]snmp-agent ...

  5. 01 Django REST Framework 介绍

    01-Django REST Framework的介绍 Django REST框架是一个用于构建Web API的强大而灵活的工具包. 您可能希望使用REST框架的一些原因: 1. Web可浏览API对 ...

  6. [Loadrunner参数化]一个文件输两列参数的取值

    关于LoadRunner参数化的内容,在脚本开发中属于非常重要的一个知识点.关于这部分知识,在书上和网上到处都能找到,本篇只讲一种特殊情况:一个参数化文件为File类型,有多列值,如何进行参数化取值. ...

  7. H5 15-交集选择器

    15-交集选择器 我是段落 我是段落 我是段落 我是段落 我是段落 <!DOCTYPE html> <html lang="en"> <head> ...

  8. html js 表单提交前检测数据

    通过使用form的onsibmit来控制是否提交数据 返回值为真是提交,其他不变,示例如下: JS部分 function check() { var newPwd = document.getElem ...

  9. httpd sshd firewalld 服务后面的d的意思

    在操作系统中,一般系统的服务都是以后台进程的方式存在,而且都会常驻系统中,直到关机才结束.这类服务也称Daemon,在Linux系统中就包含许多的Daemon. 判断Daemon最简单的方法就是从名称 ...

  10. 关于PHP的那些坑

    因为PHP是弱类型语言,常常会发生许多意想不到的问题,所以,我们再次一一细数这些我们踏过的坑!!! 1) foreach中自动回将key为数值的转化成整型,造成无法匹配 function transl ...