Grey_Wing @ 2023-10-19 20:44:35
有句话说得好“十年OI一场空,不开long long见祖宗”。
建议你们检查一下long long开没开。
还有3天就要考试了,预祝大家考试顺利(不要忘记开long long哦)
by SZX__HAPPY @ 2023-10-19 20:48:09
@xjy20100311 6
by SZX__HAPPY @ 2023-10-19 20:49:00
@xjy20100311 关键是我开int也AC了啊
by Grey_Wing @ 2023-10-19 20:53:51
@szx20100828 我开int 60分WA后四个点,数据下载下来一看发现和它的输出一模一样,然后就想是不是没开long long的缘故,试了一下,果然是的……
但是,我不知道为什么你就过了,我看了一下数据范围,我个人认为不需要开long long(有可能是机子的问题)
by fyder_anran @ 2023-10-19 20:57:13
贴上我的AC代码(用的是结构体数组)
#include <bits/stdc++.h>
using namespace std;
const int N=301;
struct Sama{int mc,zf,yw,sx,yy;}a[N];
bool cmp(Sama s1,Sama s2)
{
if(s1.zf==s2.zf) return s1.yw>=s2.yw;
return s1.zf>=s2.zf;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].yw>>a[i].sx>>a[i].yy;
a[i].zf=a[i].yw+a[i].sx+a[i].yy;
a[i].mc=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].mc<<' '<<a[i].zf<<endl;
}
return 0;
}
这一题n<=300而且各科成绩都在100以内,不可能需要开long long
肯定是其他地方的错误()
by fyder_anran @ 2023-10-19 20:58:21
@xjy20100311 不会吧。你把你代码贴出来看看
by Grey_Wing @ 2023-10-19 21:05:57
#include "algorithm"
#include "iostream"
#define ll long long
using namespace std;
ll n;
struct node{
ll id, chinese, maths, english;
ll sum;
}a[305];
bool cmp(node a,node b){
if(a.sum==b.sum){
if(a.chinese==b.chinese) return a.id<b.id;
else return a.chinese>b.chinese;
}
return a.sum>b.sum;
}
int main(){
// freopen("P1093_7.in","r",stdin);
// freopen("P1093_7.ans","w",stdout);
scanf("%lld",&n);
for(ll i=1;i<=n;i++){
scanf("%lld %lld %lld",&a[i].chinese,&a[i].maths,&a[i].english);
a[i].id=i;
a[i].sum=a[i].chinese+a[i].maths+a[i].english;
}
sort(a+1,a+n+1,cmp);
for(ll i=1;i<=5;i++){
printf("%lld %lld\n",a[i].id,a[i].sum);
}
return 0;
}
by Grey_Wing @ 2023-10-19 21:06:32
@shaoziqi
by SZX__HAPPY @ 2023-10-19 21:08:27
@xjy20100311
#include<bits/stdc++.h>
using namespace std;
int n,b,c,d;
struct s{
int x;
int y;
int z;
}a[301];
bool cmp(s a,s b){
if(a.y==b.y){
if(a.z==b.z){
return a.x<b.x;
}else{
return a.z>b.z;
}
}else{
return a.y>b.y;
}
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>b>>c>>d;
a[i].x=i;
a[i].y=b+c+d;
a[i].z=b;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].x<<" "<<a[i].y<<endl;
}
return 0;
}
by fyder_anran @ 2023-10-19 21:12:13
@xjy20100311 这个错在哪里啊喂
by Grey_Wing @ 2023-10-19 21:15:00
@shaoziqi 如果我知道的话就不会WA那么多次了……