题目: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奖学金的更多相关文章

  1. 洛谷 P1583 魔法照片

    P1583 魔法照片 题目描述 一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人.佳佳按照与他们的关系好坏的程度给每个人赋予了一个初始权值W[i].然后将初 ...

  2. 洛谷 P1583 魔法照片【二级结构体排序】

    题目描述 一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人.佳佳按照与他们的关系好坏的程度给每个人赋予了一个初始权值W[i].然后将初始权值从大到小进行排序 ...

  3. (水题)洛谷 - P1583 - 魔法照片

    https://www.luogu.org/problemnew/show/P1583 设计一个strcut cmp用来比较,就可以了. #include<bits/stdc++.h> u ...

  4. 洛谷P1583 魔法照片【模拟+排序】

    一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人.佳佳按照与他们的关系好坏的程度给每个人赋予了一个初始权值W[i].然后将初始权值从大到小进行排序,每人就有 ...

  5. 洛谷P1583 魔法照片

    https://www.luogu.org/problem/P1583 话不多说,其实就是模拟,然后,各种繁琐 #include<bits/stdc++.h> using namespac ...

  6. 洛谷P1583——魔法照片(结构体排序)

    https://www.luogu.org/problem/show?pid=1583#sub 题目描述 一共有n(n≤20000)个人(以1--n编号)向佳佳要照片,而佳佳只能把照片给其中的k个人. ...

  7. Java实现 洛谷 P1583 魔法照片

    import java.util.*; class Main{ public static void main(String[] args) { Scanner in = new Scanner(Sy ...

  8. 洛谷 U87561 魔法月饼

    洛谷 U87561 魔法月饼 洛谷传送门 题目背景 \(9102\)年的中秋节注定与往年不同...因为在\(9102\)年的中秋节前夕,\(Seaway\)被告知今年的中秋节要新出一款月饼--魔法月饼 ...

  9. [洛谷P1822] 魔法指纹

    洛谷题目连接:魔法指纹 题目描述 对于任意一个至少两位的正整数n,按如下方式定义magic(n):将n按十进制顺序写下来,依次对相邻两个数写下差的绝对值.这样,得到了一个新数,去掉前导0,则定义为ma ...

随机推荐

  1. Java 基础【17】 异常与自定义异常

    1.异常的分类 Throwable 是所有异常类的基类,它包括两个子类:Exception 和 Error. a. 错误 (Error) 错误是无法难通过程序来解决的,所以程序不应该抛出这种类型的对象 ...

  2. 每天一个linux命令(1):pwd命令

    1.命令简介 pwd(print work directory 打印当前目录)命令以绝对路径的方式显示用户当前工作目录. 2.用法 pwd [-LP] 3.选项 -L --logical 当目录为连接 ...

  3. 抓取epsg.io的内容

    简述 epsg.io是一个查询EPSG坐标系相关信息的好网站,内容很全.有各种格式的定义可以直接下载,也有坐标系的范围名称等相关信息,所以想抓取这些信息下来,方便对接各个系统. epsg.io本身是开 ...

  4. C#:网络传输问题

    1.Http Post Header 中文数据值,服务端接收Header 中文数据值乱码问题: 客户端:    Encoding utf8Encoding = Encoding.GetEncoding ...

  5. Chrome F12 温故而知新 :因为重定向导致清空Network信息

    虽然我以前都是用Fiddler 4来作为解决方案.但实际上可以勾选 [Preserve log]来保存日志 这样就不担心因为页面重定向导致清空了日志了

  6. Android Studio updating indices 一直刷新和闪烁

    Android Studio 更新到了 3.1.3 版本,在导入了工程以后,一直出现了 updating indices 刷新的情况,造成闪烁,在切换到其他视图以后,Android Studio 会一 ...

  7. iOS的动态代理模式的实现

    动态代理模式的应用很多,特别是在不能修改被代理类的前提下,要对执行某些方法时需要打log或者捕捉异常等处理时,是一个非常方便的方法.只需要少量修改客户端(场景类)代码和添加一个代理类就可以实现,这个符 ...

  8. 【Spark 深入学习 01】 Spark是什么鬼?

    经过一段时间的学习和测试,是时候给spark的学习经历做一个总结了,对于spark的了解相对晚了写.春节期间(预计是无大事),本博准备推出20篇左右spark系列原创文章(先把牛吹出去再说) ,尽量将 ...

  9. linux每日命令(35):grep命令

    Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...

  10. c++默认参数函数注意事项

    再有默认参数的函数中,一般我们都把默认参数放在声明处而不是定义处. 如果声明和定义都有默认参数,编译器将会报错. 调用含有默认实参的函数时,我们可以包含参数,也可以省略. 有默认参数的函数,我们可以不 ...