Problem A

Between the Offices

水题,水一水。

 #include<bits/stdc++.h>
using namespace std;
int n;
char s[];
int main()
{
cin>>n;
int cnt1=,cnt2=;
scanf("%s",s);
for(int i=;i<n-;i++)
{
if(s[i]=='S' && s[i+]=='F') cnt1++;
else if(s[i]=='F' && s[i+]=='S') cnt2++;
}
if(cnt1>cnt2) puts("YES");
else puts("NO");
return ;
}

Problem B

Save the problem!

题目大意:给你数字n,让你给出一个钱的总数m,和钱的种类n个,要求用这些种类的钱

构成m的种数为n。

思路:我是用5和2两种钱构造的,我们考虑构成10 的种数一共只有两种,一种是2 2 2 2 2,另一种是

5 5,那么20 就是三种,30就是四种,40就是五种,一直这样构造下去,忘了考虑一种情况WA了一次。。。

 #include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
scanf("%d",&n);
if(n==)
{
puts("1 1");
puts("");
return ;
}
printf("%d 2\n",(n-)*);
puts("5 2");
return ;
}

Promblem C

Ordering Pizza

题目大意:现在有n个人需要吃si 片披萨,一共有两种披萨A,B,第i个人吃一片A披萨获得的

愉悦值为ai,B为bi,一块披萨能分成S片,我们要买最少的披萨,问你最大愉悦值是多少。

思路:我们先让每个人吃获得愉悦值大的披萨,然后统计A披萨的片数和B披萨的片数,

A和B对S 取膜,剩下的就是不确定的,如果A+B>S则买两种披萨各一个,如果A+B<=S

则买一个披萨,两种披萨都模拟一遍取愉悦值大的。

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+;
ll _abs(ll x)
{
if(x>=) return x;
else return -x;
}
struct node
{
ll s,a,b;
bool operator < (const node &rhy)const
{
return _abs(a-b)<_abs(rhy.a-rhy.b);
}
}p[N];
ll n,S;
ll work(ll c1,ll c2)
{
ll ans=;
if(c1)
{
for(int i=;i<n;i++)
{
if(p[i].a<p[i].b) continue;
if(p[i].s>=c1) ans+=c1*(p[i].a-p[i].b);
else ans+=p[i].s*(p[i].a-p[i].b);
c1-=p[i].s;
if(c1<=) break;
}
}
else
{
for(int i=;i<n;i++)
{
if(p[i].a>=p[i].b) continue;
if(p[i].s>=c2) ans+=c2*(p[i].b-p[i].a);
else ans+=p[i].s*(p[i].b-p[i].a);
c2-=p[i].s;
if(c2<=) break;
}
}
return ans;
}
int main()
{
cin>>n>>S;
ll sum=,ans=;
ll res1=,res2=;
for(int i=;i<n;i++)
{
scanf("%I64d%I64d%I64d",&p[i].s,&p[i].a,&p[i].b);
ans+=p[i].s*max(p[i].a,p[i].b);
if(p[i].a>=p[i].b) res1+=p[i].s;
else res2+=p[i].s;
}
res1=res1%S; res2=res2%S;
if(res1+res2>S)
{
printf("%I64d\n",ans);
return ;
}
ll res=1e18;
sort(p,p+n);
res=min(res,work(,res2));
res=min(res,work(res1,));
printf("%I64d\n",ans-res);
return ;
}

Problem E

Buy Low Sell High

题目大意:给你一些股票每天的价格,每一天你可以选择买,卖,或者啥都不干,问你

利润最大多少。

思路:智力题,我不会! 用优先队列维护最小值,我们取一个数b,如果这个数比堆顶的

元素a小,则将b加入优先队列,如果b比a大,删除a,加入两个b,(b-a)加入ans,

第一个b相当于把a变成了b,第二个b是自身。

 #include<bits/stdc++.h>
using namespace std;
const int N=*1e5+;
int n,a[N];
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%d",&a[i]);
priority_queue<int,vector<int>,greater<int> > Q;
long long ans=;
for(int i=;i<=n;i++)
{
if(Q.empty())
{
Q.push(a[i]);
continue;
}
int t=Q.top();
if(t>=a[i]) Q.push(a[i]);
else
{
ans+=a[i]-t;
Q.pop();
Q.push(a[i]); Q.push(a[i]);
}
}
printf("%I64d\n",ans);
return ;
}

Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0 - Round 2)的更多相关文章

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

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

  2. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)

    Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...

  3. Codeforces Round #500 (Div. 2) [based on EJOI]

    Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bit ...

  4. Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)

    Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++ ...

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

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

  6. Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics)

    A. Even Subset Sum Problem 题意 给出一串数,找到其中的一些数使得他们的和为偶数 题解 水题,找到一个偶数或者两个奇数就好了 代码 #include<iostream& ...

  7. Codeforces Round #507 (Div. 2, based on Olympiad of Metropolises) D mt19937

    https://codeforces.com/contest/1040/problem/D 用法 mt19937 g(种子); //种子:time(0) mt19937_64 g(); //long ...

  8. (AB)Codeforces Round #528 (Div. 2, based on Technocup 2019 Elimination Round

    A. Right-Left Cipher time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)

    A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...

随机推荐

  1. 第k个素数

    题目描述 Output the k-th prime number. 输入描述: k≤10000 输出描述: The k-th prime number. #include <iostream& ...

  2. 使用Eclipse Memory Analyzer 进行JAVA内存泄露分析

    一,安装 Eclipse Memory Analyzer 在Memory Analyzer的官网找到 update site的地址:

  3. 20155332 2016-2017-2 《Java程序设计》第5周学习总结

    学号 2016-2017-2 <Java程序设计>第X周学习总结 教材学习内容总结 1.Java中的所有不正常类都继承于Throwable类.Throwable主要包括两个大类,一个是Er ...

  4. VC++中LogFont设置字体(转)

    LOGFONT是Windows内部字体的逻辑结构,主要用于设置字体格式,其定义如下:typedef struct tagLOGFONTA{LONG lfHeight;LONG lfWidth;LONG ...

  5. C++常量 运算符

    \n  换行   光标移到下一行             \0  空值                               \t   水平制表符 \r   回车  光标回到本行开头      ...

  6. Django学习手册 - 正则URL路由配置/路由分发

    ############################################### 总结: 一.url路由配置: 方式一:(通过url链接get获取) 方式二:(url路由匹配方式获取-拓 ...

  7. struct 与 class 的区别

    C++中的struct对C中的struct进行了扩充,它已经不再只是一个包含不同数据类型的数据结构了,它已经获取了太多的功能. struct能包含成员函数吗? 能! struct能继承吗? 能!! s ...

  8. http转发

    该http转发,我感觉有点类似于负载均衡(我还没有详细了解过负载均衡). 现在有三个站点,想自己建立一个web,对三个站点进行整合,效果如图所示: a)现状:浏览器需要访问3个站点,需要记住3个地址, ...

  9. totastmessage 触发事件后浮框消失的方法

    1. 前言 通过查了官放的文档,发现没有 totastmessage 触发事件后,浮框消失的方法,然后通过研究了下点击关闭时的源码,得到了一个的解决方案. 2. 样例代码如下 $("#dro ...

  10. python安装虚拟环境pipenv

    python里如果多个多个项目同时引用包,就会涉及到包版本的问题,包不同版本管理的问题可以用虚拟环境来管理, 创建虚拟环境,这里是用官方推荐的pipenv来创建 先用pip命令行安装pipenv pi ...