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. CSS魔法(四)常用属性

    元素的显示与隐藏 display.visibility.overflow 在CSS中有三个显示和隐藏的单词比较常见,我们要区分开,他们分别是 display.visibility 和 overflow ...

  2. 用Python中的re做信息筛选

    背景 平时工作中,我们经常会处理大量的元数据(Raw Data),而一般的文件编辑器只能一次查询一个关键字,这就难以连续的分析元数据,比如分析产品日志文件(log),日志可能包括很多informati ...

  3. Springboot使用FastJson后,接口返回中文乱码的问题解决。

    哎,天下文章一大抄,到处都是一模一样的教你怎么替换掉jackson成fastjson的,可后续中文乱码网上居然没一篇文章.翻了一会源码还是写个文章共享下吧.免得后来人又浪费时间折腾. 在springb ...

  4. DjangoAdmin自定义过滤器

    class UserIDFilter(admin.SimpleListFilter): # 自定义用户查询过滤器 title = _('关联用户') parameter_name = 'user_id ...

  5. latex对齐问题

    数学公式居中:可以在公式前后各加两个$$,就可以了 一行对齐:左对齐\leftline{内容} 居中\centerline{内容} 右对齐\rightline{内容} 多行或者段落对齐: 左对齐 \b ...

  6. CEdit使用(Edit Control控件)

    CEdit使用(Edit Control控件) 编辑框只读 属性 Read Only等于 True,就有了只读效果 密码框 属性 Password 等于 True,就有了密码效果 获取值/赋予值 Up ...

  7. GCC 符号表小结【转】

    转自:https://blog.csdn.net/swedenfeng/article/details/53417085 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog ...

  8. python将图片转换为Framebuffer裸数据格式(终端显示图片)【转】

    转自:https://www.cnblogs.com/zqb-all/p/6107905.html 要在ubuntu终端显示图片或者在板子的LCD显示图片,Framebuffer是一个简单易用的接口, ...

  9. Project Euler Problem6

    Sum square difference Problem 6 The sum of the squares of the first ten natural numbers is, 12 + 22  ...

  10. Tomcat:在centos中做成自启动服务

    # 创建一个启动脚本文件,脚本内容见下 vi /etc/init.d/tomcat #!/bin/bash # /etc/rc.d/init.d/tomcat # init script for to ...