P1223过了样例,全WA,第一个测试点就是样例(但我确实过了样例),求助
  • 板块P1223 排队接水
  • 楼主Aiza
  • 当前回复6
  • 已保存回复6
  • 发布时间2021/8/17 16:30
  • 上次更新2023/11/4 10:19:11
查看原帖
P1223过了样例,全WA,第一个测试点就是样例(但我确实过了样例),求助
209359
Aiza楼主2021/8/17 16:30
#include<bits/stdc++.h>
using namespace std;
struct node{
	int t;
	int num;
}a[1005];
bool cmp(const node &x, const node &y){
	return (x.t == y.t) ? (x.num < y.num ) : (x.t < y.t);
}
int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
    	a[i].num = i;
    	scanf("%d", &a[i].t);
    }
    sort(a + 1, a + 1 + n, cmp);
    int v = 0;
    for (int i = 1; i <= n; i++){
    	printf("%d ", a[i].num);
    	v += a[i].t * (n - i);
    }
    printf("\n%.2llf", v * 1.0 / n);
  	return 0;
}
2021/8/17 16:30
加载中...