发布网友 发布时间:2024-03-08 20:48
共2个回答
热心网友 时间:2024-12-02 03:45
#include <bits/stdc++.h>
using namespace std;
typedef struct
{ char name[20];
int time;
} stu;
stu a[200000];
bool cmp(stu a,stu b)
{ return a.time>b.time||a.time==b.time&&strcmp(a.name,b.name)>0;
}
int main()
{ int n,i,j,h,m,h0,m0;
scanf("%d%d:%d",&n,&h0,&m0);
m0+=60*h0;
for(i=0; i<n; i++)
{ scanf("%s%d:%d",a[i].name,&h,&m);
a[i].time=60*h+m;
}
//cout<<"============\n";//此行可删去
sort(a,a+n,cmp);
for(i=0; a[i].time>m0; i++)
printf("%s %d:%02d\n",a[i].name,a[i].time/60,a[i].time%60);
return 0;
}
追问不行啊,网站评测只有20分,有些地方不对。追答
把<打错了方向。已经改过来了:
#include <bits/stdc++.h>
using namespace std;
typedef struct
{ char name[20];
int time;
} stu;
stu a[200000];
bool cmp(stu a,stu b)
{ return a.time>b.time||a.time==b.time&&strcmp(a.name,b.name)<0;
}
int main()
{ int n,i,j,h,m,h0,m0;
scanf("%d%d:%d",&n,&h0,&m0);
m0+=60*h0;
for(i=0; i<n; i++)
{ scanf("%s%d:%d",a[i].name,&h,&m);
a[i].time=60*h+m;
}
//cout<<"============\n";//此行可删去
sort(a,a+n,cmp);
for(i=0; a[i].time>m0; i++)
printf("%s %d:%02d\n",a[i].name,a[i].time/60,a[i].time%60);
return 0;
}
热心网友 时间:2024-12-02 03:46
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int T,n;
struct STU{
string s;
int t;
bool operator < (const STU&a) const {
if(t!=a.t) return t>a.t;
return s<a.s;
}
};
STU student[200005];
int main(){
string T_temp;
cin>>n>>T_temp;
int hoursa=(T_temp[0]-'0')*10+(T_temp[1]-'0');
int minutea=(T_temp[3]-'0')*10+(T_temp[4]-'0');
T=hoursa*60+minutea;
int temp=0;
for(int i=0;i<n;i++){
string s;
string t;
cin>>s>>t;
int hours=(t[0]-'0')*10+(t[1]-'0');
int minute=(t[3]-'0')*10+(t[4]-'0');
int time=hours*60+minute;
time-=T;
if(time<=0) continue;
STU temp2;
temp2.s=s;
temp2.t=time;
student[temp]=temp2;
temp++;
}
sort(student,student+temp);
for(int i=0;i<temp;i++){
cout<<student[i].s<<" ";
int ttt=student[i].t+T;
cout<<ttt/60<<":"<<ttt-(ttt/60)*60<<endl;
}
return 0;
}