求大神指点
  • 板块灌水区
  • 楼主honeygrb
  • 当前回复8
  • 已保存回复8
  • 发布时间2024/8/6 21:35
  • 上次更新2024/8/6 23:17:49
查看原帖
求大神指点
1416724
honeygrb楼主2024/8/6 21:35

有N个人参加了数学、信息学考试,考试成绩都是范围在 [0, 1000 ] 的正整数,如果学生A的2科成绩都比学生B的2科成绩少,A就是绝对比B差。现在每个人想知道绝对比自己差的人有多少?N范围都在[1,100000]

#include<bits/stdc++.h>
using namespace std;
const int MAXN=100000;
struct student
{
    int com;
    int mat;
}stu[MAXN];
int main(){
    int n;
    cin>>n;
    int f[n]; 
    memset(f,0,sizeof(f));

    for (int i=0; i<n; i++)
    {
    	scanf("%d %d",&stu[i].mat,&stu[i].com);
    	for (int j=0; j<i; j++)
    	{
    		if (stu[j].mat<stu[i].mat && stu[j].com<stu[i].com)
    			f[i]++;
    		if (stu[j].mat>stu[i].mat && stu[j].com>stu[i].com)
    			f[j]++;
		}
	}
       
    for (int i=0; i<n; i++)
		cout<<f[i]<<'\n';
        
    return 0;
}

报stdMoniter_timeLimit_exceeded,请问为啥?怎么改

2024/8/6 21:35
加载中...