1、3431:【例75.2】 区间合并
ACWing 803. 区间合并(C++)
算法基础之离散化&区间合并-c++&python
ACwing 803 区间合并
【AcWing.803】区间合并
/*
7620:区间合并02
1236:区间合并
http://ybt.ssoier.cn:8088/problem_show.php?pid=1236
*/
#include<cstdio>
int t[20020];//算是个桶吧
int main( void )
{
bool p=1;
int a,b,n,min=20020,max=0;
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d%d",&a,&b); //输入闭区间
if(a<min) min=a; //记录最大值与最小值
if(b>max) max=b;
//所有区间内的数为1(乘2是因为防止输入【1,2】【3,4】情况)
for(int j=a*2;j<=b*2;j++)
{
t[j]=1;
}
}
for(int i=min*2;i<=max*2;++i)
if(t[i]==0)p=0; //判断 p为判断参数
if(p==0) printf("no");
else
{
if(p==1) printf("%d %d",min,max);
}
return 0;
}
2、3432:【例75.3】 谁拿了最多奖学金
[例 75.3] 谁拿了最多奖学金
1839:【05NOIP提高组】谁拿了最多奖学金
C++到算法,从零开始学——谁拿了最多奖学金
信息学奥赛一本通 1839:【05NOIP提高组】谁拿了最多奖学金
《信息学奥赛一本通》题解_1839_【05NOIP提高组】谁拿了最多奖学金
/*
NOIP2005复赛 提高组 第一题(方法二)
谁拿了最多奖学金
http://noi.openjudge.cn/ch0109/04/
https://bbs.codeaha.com/problem-10017.html
https://www.luogu.org/problemnew/show/P1051
*/
#include <iostream>
#include <string>
using namespace std;
//结构体及全局变量定义
struct student //存储学生信息
{
string name; //名字,用string避免越界
int score; //得分
int cscore; //班级评议得分
char head; //是否为学生干部(Y/N)
char west; //是否为西部学生(Y/n)
int arcitle; //论文数量
};
student a[105]; //学生信息
int size,total=0; //学生数量,总奖学金
//读入所有数据的函数
void initial() //初始化
{
cin>>size;
for(int i=1;i<=size;i++)
{
cin>>a[i].name>>a[i].score>>a[i].cscore>>a[i].head>>a[i].west>>a[i].arcitle; //cin读入会自动跳过空格,读入字符比什么都方便
}
}
//计算奖学金数量
int money(student n) //对某个student对象计算奖学金数量
{
int ans=0;
if(n.score>80&&n.arcitle>=1) ans+=8000; //院士奖学金
if(n.score>85&&n.cscore>80) ans+=4000; //五四奖学金
if(n.score>90) ans+=2000; //成绩优秀奖
if(n.score>85&&n.west=='Y') ans+=1000; //西部奖学金
if(n.cscore>80&&n.head=='Y') ans+=850; //班级贡献奖
return ans; //返回获得奖学金的数量
}
int main()
{
initial(); //初始化输入
int Max=-1,Maxno=1; //最大值和最大值所在的编号
for(int i=1;i<=size;i++) //穷举最多奖学金,不需要排序
{
if(money(a[i])>Max) //如果比最大值大
{
Max=money(a[i]);
Maxno=i;
}
total+=money(a[i]); //我就多算几遍不超时
}
//输出
cout<<a[Maxno].name<<endl<<Max<<endl<<total<<endl;
return 0;
}
3、3433:练75.1奖学金【07NOIP普及组】
练 75.1 奖学金
1938:【07NOIP普及组】奖学金
1179:奖学金
#include <stdio.h>
#include <stdlib.h>
//定义结构体,可以想象成一个表格
struct student
{
int no;
int l;
int m;
int e;
int sum;
};
//相当于申请在表格中加入内容
struct student stu[302];
void sort(int n)
{
int t,i,j;
struct student s_t;
for(i=1;i<6;i++)
for(j=i+1;j<n+1;j++)
if(stu[i].sum<stu[j].sum||stu[i].sum==stu[j].sum&&stu[i].l<stu[j].l||stu[i].sum==stu[j].sum&&stu[i].l==stu[j].l&&stu[i].no>stu[j].no)
{
s_t=stu[i];
stu[i]=stu[j];
stu[j]=s_t;
}
}
//建立函数,换位,根据成绩和学号排序
int main()
{
int n,i;
scanf("%d",&n);
for(i=1;i<n+1;i++)
{
stu[i].no=i;//标记学号
scanf("%d %d %d",&stu[i].l,&stu[i].m,&stu[i].e);
stu[i].sum=stu[i].l+stu[i].m+stu[i].e;//求每个学号下的每个人的总成绩
}
sort(n);
for(i=1;i<6;i++)
printf("%d %d\n",stu[i].no,stu[i].sum);
}
4、3434:练75.2采购奖品
采购奖品
/*
3434:练75.2采购奖品
http://bas.ssoier.cn:8086/problem_show.php?pid=3434
https://blog.csdn.net/user_qym/article/details/104083504
*/
#include<iostream>
#include<cstring>
using namespace std;
int a[10001],b[10001];
int main()
{
int k,n,i,j,v=0;
cin>>k>>n;
for(i=1;i<=n;i++)
cin>>a[i]>>b[i];
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
if(a[i]>a[j])
{
swap(a[i],a[j]);
swap(b[i],b[j]);
}
}
}
int sum=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=b[i];j++)
{
sum+=a[i];
if(sum>=k)
break;
v++;
}
if(sum>=k)
break;
}
cout<<v;
return 0;
}
5、3435:练75.3 日期排序
(c/c++) sort cmp规则 题:日期排序
C++程序设计题解:日期排序
日期排序(C++)
/*
3435:练75.3 日期排序
http://bas.ssoier.cn:8086/problem_show.php?pid=3435
*/
#include <bits/stdc++.h>
using namespace std;
struct st{
int d,m,y;
};
st a[100000+10];
bool cmp( st x,st z){
return x.y<z.y ||
x.y==z.y && x.d==z.d && x.m<z.m;
}
int main( )
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
scanf("%d/%d/%d",&a[i].d,&a[i].m,&a[i].y);
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++)
{
if( a[i].d<10)
{
cout<<0<<a[i].d<<'/';
}
else
{
cout<<a[i].d<<'/';
}
if( a[i].m<10)
{
cout<<0<<a[i].m<<'/';
}
else
{
cout<<a[i].m<<'/';
}
if( a[i].y<10)
{
cout<<0<<a[i].y;
}
else
{
cout<<a[i].y;
}
cout<<endl;
}
return 0;
}
6、3436:【例76.1】 病人排队
[例 76.1] 病人排队
1183:病人排队
3065病人排队
《信息学奥赛一本通》题解_1183_病人排队
[openjudge习题讲解]1.10编程基础之简单排序-8病人排队
奥赛一本通专题串讲——结构体数组排序,1147,1176,1178,1179,1183,全网最详
奥赛一本通专题串讲——结构体数组排序,1147,1176,1178,1179,1183,全网最详细讲解_哔哩哔哩_bilibili
noi 1.10 08:病人排队
[结构体排序]NOIP CSP c++经典例题选讲Day151病人排队
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
struct Patient {
string id; // 病人编号
int age; // 病人年龄
int order; // 病人登记的先后顺序
};
bool cmp(Patient a, Patient b) {
if (a.age >= 60 && b.age >= 60) { // 两个都是老年人,按照年龄从大到小排序
if (a.age == b.age) return a.order < b.order; // 年龄相同按照登记先后顺序
return a.age > b.age;
}
else if (a.age >= 60) return true; // a 是老年人,优先级更高,sort函数默认从小到大排序,即return a<b 所以当return true 时默认a<b为true,从小到大排序输出a。
else if (b.age >= 60) return false; // b 是老年人,优先级更高,
else return a.order < b.order; // 都是非老年人,按照登记先后顺序
}
int main() {
int n;
cin >> n;
Patient patients[n];
for (int i = 0; i < n; i++) {
cin >> patients[i].id >> patients[i].age;
patients[i].order = i; // 记录登记的先后顺序
}
sort(patients, patients + n, cmp);
for (int i = 0; i < n; i++) {
cout << patients[i].id << endl;
}
return 0;
}
7、3437:练76.1生日排序
洛谷:P1104 生日 (结构体排序)
生日排序
生日排序_样例输入 3 qwb 1996 6 30 gyt 1995 7 28 ww 1996 6 30 样例-CSDN博客
生日排序 计蒜客 - T1715
生日排序 计蒜客 - T1715_爱思考的小伙的博客-CSDN博客
生日排序_样例输入 3 qwb 1996 6 30 gyt 1995 7 28 ww 1996 6 30 样例-CSDN博客
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct T{
string name;
int y,m,d;
int id;
}stu[110];
bool cmp(T a,T b){
if(a.y!=b.y) return a.y<b.y;
if(a.m!=b.m) return a.m<b.m;
if(a.d!=b.d) return a.d<b.d;
return a.id>b.id;
}
int main(){
int n;cin >> n;
for(int i=0;i<n;i++){
cin >> stu[i].name>> stu[i].y >> stu[i].m >> stu[i].d;
stu[i].id=i;
}
sort(stu,stu+n,cmp);
for(int i=0;i<n;i++){
cout << stu[i].name << endl;
}
return 0;
}
8、3438:练76.2 精挑细选
精挑细选c++
精挑细选(c++)
/*
3438:练76.2 精挑细选
http://bas.ssoier.cn:8086/problem_show.php?pid=3438
*/
#include <bits/stdc++.h>
using namespace std;
int n;
struct node{
int L;
int d;
int t;
};
node a[1005],*p;
bool cmp(node x,node y){
return x.L<y.L ||
x.L==y.L && x.d>y.d ||
x.L==y.L && x.d==y.d && x.t<y.t;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].L>>a[i].d>>a[i].t;
}
p=max_element(a+1,a+n+1,cmp);
cout<<(*p).t;
return 0;
}
9、3439:练76.3 分数线划定
练 76.3 分数线划定
1180:分数线划定
1946:【09NOIP普及组】分数线划定
05 分数线划定
P1068 [NOIP2009 普及组] 分数线划定
P1068 [NOIP2009 普及组] 分数线划定 1
分数线划定 NOIP普及组2009
C++到算法,从零开始学——分数线划定
NOIP普及组C++真题解析【分数线划定】寒假算法普及
分数线划定 【NOIP2009 普及组】排序
C++到算法,从零开始学——分数线划定(选排)
[NOIP2009 普及组] 分数线划定
P1068分数线划定
P1068 [NOIP2009 普及组] 分数线划定
10、3440:【例77.1】模拟链表
/*
3440:【例77.1】模拟链表
http://bas.ssoier.cn:8086/problem_show.php?pid=3440
*/
#include <bits/stdc++.h>
using namespace std;
struct node{
int v;
int next;
};
node a[200001];
int n,m,p;
int k[5001],c[5001];
void insert(int u,int v)
{
a[++p].v=v;
a[p].next=c[u];
c[u]=p;
k[u]++;
}
int main( void )
{
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int u,v;
cin>>u>>v;
insert(u,v);
insert(v,u);
}
for(int i=1;i<=n;i++)
{
cout<<k[i]<<' ';
for(int j=c[i];j>0;j=a[j].next)
{
cout<<a[j].v<<' ';
}
cout<<endl;
}
return 0;
}
信息学奥赛一本通 编程启蒙C++版》3001 -- 3020
《信息学奥赛一本通 编程启蒙C++版》3001-3030
《信息学奥赛一本通 编程启蒙C++版》3031-3099
《信息学奥赛一本通 编程启蒙C++版》3390-3395、3451-3465
《信息学奥赛一本通 编程启蒙C++版》3021 -- 3040
《信息学奥赛一本通 编程启蒙C++版》3041 -- 3060
《信息学奥赛一本通 编程启蒙C++版》3061 -- 3080
《信息学奥赛一本通 编程启蒙C++版》3081 -- 3100
《信息学奥赛一本通 编程启蒙C++版》3101 -- 3120
《信息学奥赛一本通 编程启蒙C++版》3100-3154
《信息学奥赛一本通 编程启蒙C++版》3451 -- 3466
信息学奥赛一本通-编程启蒙 第1-17集
C++版-----信息学奥赛一本通-----编程启蒙(1-19)
《信息学奥赛一本通编程启蒙(C++版)》题库题解
《信息学奥赛一本通 编程启蒙C++版》第1课 -- 第86课
信息学奥赛一本通-编程启蒙 解题目录(部分)
一本通编程启蒙 题解(2023.11.20)
信息学奥赛一本通题解、题目详解、视频集
小学生讲C++(2023.12.03)
从近三年CSP获奖情况看小学组信奥趋势!
【收藏】2024强基计划与综合评价特招政策
第32集 | 1到4年级适合学的是C++语言,其他的语言都是知识孩子的玩具而已。
小学生适合学C++吗?别被培训机构忽悠了
三四年级的孩子学习信奥赛早不早?
宝宝的C++、小学生C++启蒙、小学生C++入门
编程启蒙系列书籍(2023.11.24)
小学生适宜几年级开始学C++
小学生讲C++(2023.12.03)