洛谷 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 ...
随机推荐
- LeetCode Permutations问题详解
题目一 permutations 题目描述 Given a collection of numbers, return all possible permutations. For example,[ ...
- SpringCloud分布式事务TCC实现
可以参考 http://www.txlcn.org/ 的实现方式
- (原)pycharm中使用CUDA_VISIBLE_DEVICES
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/8576825.html 如果使用多gpu运行程序,可以直接使用CUDA_VISIBLE_DEVICES= ...
- 让div获取焦点
DIV获取焦点有两种方法: tabindex="0" contenteditable="true" ①:设置div为可编辑状态,则可点击获取焦点,同时div的内 ...
- [Aaronyang] 写给自己的WPF4.5 笔记13[二维自定义控件技巧-可视化状态实战,自定义容器,注册类命令,用户控件补充]
我的文章一定要做到对读者负责,否则就是失败的文章 --------- www.ayjs.net aaronyang技术分享 博文摘要:欢迎大家来支持我的<2013-2015 Aar ...
- 小型IT部门建设之我见
关于IT团队建设,一般的原则是四大块组成: 1:业务分析师,对接业务部门,把业务需求转变成技术需求 专注于BRS( Business Requirement Speci ...
- javascript es6 箭头函数
1.箭头函数示例 let add = (a,b) => a + b //没有语句块时,默认作为返回值 add(1,2); var multi = (a,b) => {ret ...
- 使用apktool.jar工具反编译和回编译Android APK 终端命令模式
1.工具准备 工具可以网上搜索下载新版本,也可以从这里Download:https://github.com/FlymeOS/tools/blob/lollipop-5.1/reverses/apkt ...
- 【LINUX】——如何配置宿主机和虚拟机IP在同一网段
宿主机:win7 10.8.2.50 255.255.255.0 虚拟机:redhat 如果使用 NAT 的网络连接方式,虚拟机的 IP 会被分配为 192.168.*.* 网段,从虚拟机 ping ...
- Java知多少(102)多媒体基础
本节介绍 Java程序播放幻灯片和动画,播放声音和视频的方法. 播放幻灯片和动画 用实例说明播放幻灯片和动画的方法. [例 12-7]小应用程序先将幻灯片读入数组在存储,单击鼠标变换幻灯片,逐张显示. ...