洛谷 P1583魔法照片 & P1051谁拿了最多奖学金 & P1093奖学金
题目:https://www.luogu.org/problemnew/show/P1583
思路:sort sort sort
//#include<bits/stdc++.h>
#include<set>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cstring>
#include<stack>
#include<algorithm> using namespace std; int n, k;
struct node{
int id, w;
}peo[];
int e[]; bool cmp(node a, node b)
{
if(a.w == b.w)return a.id < b.id;
return a.w > b.w;
} int main()
{
scanf("%d%d", &n, &k);
for(int i = ; i <= ; i++){
scanf("%d", &e[i]);
}
for(int i = ; i <= n; i++){
scanf("%d", &peo[i].w);
peo[i].id = i;
}
sort(peo + , peo + + n, cmp);
/*for(int i = 1; i <= n; i++){
printf("%d\n", peo[i].id);
}*/
for(int i = ; i <= n; i++){
peo[i].w += e[(i - ) % + ];
}
sort(peo + , peo + + n, cmp);
for(int i = ; i <= k; i++){
printf("%d ", peo[i].id);
}
printf("\n"); return ;
}
题目:https://www.luogu.org/problemnew/show/P1051
思路:模拟拿奖学金的情况,找最大值。
//#include<bits/stdc++.h>
#include<set>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cstring>
#include<stack>
#include<algorithm> using namespace std; int n;
struct node{
string name;
int sco, csco;
char ganbu, west;
int paper;
int money = ;
}stu[]; int main()
{
scanf("%d", &n);
int mmm = , id = , sum = ;
for(int i = ; i < n; i++){
cin>>stu[i].name>>stu[i].sco>>stu[i].csco>>stu[i].ganbu>>stu[i].west>>stu[i].paper;
if(stu[i].sco > && stu[i].paper >= ){
stu[i].money += ;
}
if(stu[i].sco > && stu[i].csco > ){
stu[i].money += ;
}
if(stu[i].sco > ){
stu[i].money += ;
}
if(stu[i].sco > && stu[i].west == 'Y'){
stu[i].money += ;
}
if(stu[i].csco > && stu[i].ganbu == 'Y'){
stu[i].money += ;
}
sum += stu[i].money;
if(stu[i].money > mmm){
id = i;
mmm = stu[i].money;
}
}
cout<<stu[id].name<<endl;
cout<<mmm<<endl;
cout<<sum<<endl;
return ;
}
题目:https://www.luogu.org/problemnew/show/P1093
思路:sort
//#include<bits/stdc++.h>
#include<set>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cstring>
#include<stack>
#include<algorithm> using namespace std; struct node{
int id;
int chinese;
int math;
int eng;
}stu[];
int n; bool cmp(node a, node b)
{
if(a.chinese + a.math + a.eng == b.chinese + b.math + b.eng){
if(a.chinese == b.chinese){
return a.id < b.id;
}
else return a.chinese > b.chinese;
}
else return a.chinese + a.math + a.eng > b.chinese + b.math + b.eng;
} int main()
{
scanf("%d", &n);
for(int i = ; i <n; i++){
scanf("%d%d%d", &stu[i].chinese, &stu[i].math, &stu[i].eng);
stu[i].id = i + ;
}
sort(stu, stu + n, cmp);
for(int i = ; i < ; i++){
printf("%d %d\n", stu[i].id, stu[i].chinese + stu[i].math + stu[i].eng);
}
return ;
}
洛谷 P1583魔法照片 & P1051谁拿了最多奖学金 & P1093奖学金的更多相关文章
- 洛谷 P1583 魔法照片
P1583 魔法照片 题目描述 一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人.佳佳按照与他们的关系好坏的程度给每个人赋予了一个初始权值W[i].然后将初 ...
- 洛谷 P1583 魔法照片【二级结构体排序】
题目描述 一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人.佳佳按照与他们的关系好坏的程度给每个人赋予了一个初始权值W[i].然后将初始权值从大到小进行排序 ...
- (水题)洛谷 - P1583 - 魔法照片
https://www.luogu.org/problemnew/show/P1583 设计一个strcut cmp用来比较,就可以了. #include<bits/stdc++.h> u ...
- 洛谷P1583 魔法照片【模拟+排序】
一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人.佳佳按照与他们的关系好坏的程度给每个人赋予了一个初始权值W[i].然后将初始权值从大到小进行排序,每人就有 ...
- 洛谷P1583 魔法照片
https://www.luogu.org/problem/P1583 话不多说,其实就是模拟,然后,各种繁琐 #include<bits/stdc++.h> using namespac ...
- 洛谷P1583——魔法照片(结构体排序)
https://www.luogu.org/problem/show?pid=1583#sub 题目描述 一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人. ...
- Java实现 洛谷 P1583 魔法照片
import java.util.*; class Main{ public static void main(String[] args) { Scanner in = new Scanner(Sy ...
- 洛谷 U87561 魔法月饼
洛谷 U87561 魔法月饼 洛谷传送门 题目背景 \(9102\)年的中秋节注定与往年不同...因为在\(9102\)年的中秋节前夕,\(Seaway\)被告知今年的中秋节要新出一款月饼--魔法月饼 ...
- [洛谷P1822] 魔法指纹
洛谷题目连接:魔法指纹 题目描述 对于任意一个至少两位的正整数n,按如下方式定义magic(n):将n按十进制顺序写下来,依次对相邻两个数写下差的绝对值.这样,得到了一个新数,去掉前导0,则定义为ma ...
随机推荐
- 【PMP】项目采购管理~重点知识
1.合同的类型与区别 固定总价(FFP):大多数买方都喜欢这种合同,因为货物的采购价格在一开始就已确定,并且不允许改变(除非工作范围发生变更) 总价加激励费用(FPIF):这种总价合同给买方和卖方提供 ...
- python3用BeautifulSoup抓取a标签
# -*- coding:utf-8 -*- #python 2.7 #XiaoDeng #http://tieba.baidu.com/p/2460150866 from bs4 import Be ...
- java webdriver的api的封装
我们来看一下官网提供的代码写法,即最原始的写法: driver.findElement(By.id("kw")).click() 这样写是没任何问题的,但这样没有把元素对象,数据, ...
- Kriging插值法
克里金法是通过一组具有 z 值的分散点生成估计表面的高级地统计过程.与插值工具集中的其他插值方法不同,选择用于生成输出表面的最佳估算方法之前,有效使用克里金法工具涉及 z 值表示的现象的空间行为的交互 ...
- ASP.NET Web API(MVC API)
ASP.NET Web API是一个框架,可以很容易构建达成了广泛的HTTP服务客户端,包括浏览器和移动设备.是构建RESTful应用程序的理想平台的.NET框架. 上面是微软对Web API给出 ...
- Android源码阅读笔记二 消息处理机制
消息处理机制: .MessageQueue: 用来描述消息队列2.Looper:用来创建消息队列3.Handler:用来发送消息队列 初始化: .通过Looper.prepare()创建一个Loope ...
- “RESOURCE MONITOR“CPU占用特别高
背景: SQL Server 2008 R2 10.50.1600 没有设置页面文件,内存为64G,数据库分配50G cpu使用占了50%以上,平时只有10-20%,某台服务器“RESOURCE MO ...
- 【iCore1S 双核心板_FPGA】例程八:触发器实验——触发器的使用
实验现象: 在本实验中,将工程中的D触发器.JK触发器实例化,对应其真值表,用signal对其进行 检验,利用SignaTap II观察分析波形. 核心代码: module D( input CLK, ...
- 关于Python打包运行的一些思路
需求 本地开发python django应用程序,然后放到生产环境运行.使用了tensorflow,手动安装包很麻烦.生产环境不能联网,不能使用 pip freeze. 思路: 使用docker,直接 ...
- 怎么关闭win10和win8快速启动
电源选项-- 选择电源按钮的功能--- 更改当前不可用的设置-- 快速启动勾去掉