题目: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. 【转发】Cookie存储的值大小限制和个数问题

    Cookie以及LocalStorage.SessionStorage的区别 缓存机制对于用户访问网页来说是很方便的.如果将用户名,偏好设定或者其他一些数据存储到客户端,而不必每次访问网页都输入数据, ...

  2. Long polling failed, will retry in 16 seconds. appId: zeus-guard, cluster: default, namespaces: application, long polling url: null, reason: Get config services failed from···

    当dubbo应用启动之前, 如果apollo 未启动好,那么我们dubbo应用会一直等待,直到apollo准备就绪,注意其中轮询时间是从1,2,3,4,8,14,32, 方式一直增长,单位是s.

  3. CAS Maven

    https://wiki.jasig.org/display/CASUM/Best+Practice+-+Setting+Up+CAS+Locally+using+the+Maven2+WAR+Ove ...

  4. javascript中的数据结构

    Javascript中的关键字   abstract     continue      finally      instanceof      private       this boolean ...

  5. golang ----gc问题

    go程序内存占用大的问题 这个问题在我们对后台服务进行压力测试时发现,我们模拟大量的用户请求访问后台服务,这时各服务模块能观察到明显的内存占用上升.但是当停止压测时,内存占用并未发生明显的下降.花了很 ...

  6. C++的子类与父类强制转换产生的问题

    近日,在项目的一个类中如果碰上想要将子类强制转换成父类,然后再调用其父类版本的virtual虚函数. 就会出现gcc编译错误提示:error: ld returned 1 exit status gc ...

  7. CentOS下如何查看并杀死僵尸进程

    昨天服务器到期,之前的服务器由于空间小,不能满足现在的服务要求,就新购买了一个服务器,目前正在调试安装中! 在调试过程中,发现系统中有很多僵尸进程,现在就是找出这些僵尸进程,并将其杀死. 用top查看 ...

  8. ES6,Array.find()和findIndex()函数的用法

    ES6为Array增加了find(),findIndex函数. find()函数用来查找目标元素,找到就返回该元素,找不到返回undefined. findIndex()函数也是查找目标元素,找到就返 ...

  9. visio2013激活软件

    环境是 win7, 64 bit 装了 visio 2013 , 可以却不能用它来画图,在网上找了一些破解工具,大都不能解决问题.网上不靠谱的广告型文章太多了,比较头痛. 所幸,终于找到正确的破解工具 ...

  10. 基于jQuery+HTML5加入购物车代码

    基于jQuery+HTML5加入购物车代码.这是一款基于jquery+html5实现的支持累加计价的网站购物车代码.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div ...