82分求助

P1223 排队接水

#include <bits/stdc++.h> using namespace std; int n, s; struct qwq{ int t, num; } a[1005]; bool cmp(qwq i, qwq j){ if (i.t < j.t) return 1; if (i.t == j.t && i.num < j.num) return 1; return 0; } int main(){ scanf("%d", &n); for (int i = 1; i <= n; ++i){ scanf("%d", &a[i].t); a[i].num = i; } sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n; ++i){ printf("%d%c", a[i].num, i == n ? '\n' : ' '); s += a[i].t * (n - i); } cout << fixed << setprecision(2) << s * 1.0 / n << endl; return 0; } 82分
by leoair @ 2019-07-20 09:11:18


@[CCGTA5888](/space/show?uid=149703) 开long long
by doughty @ 2019-07-31 12:38:23


@[leoair](/space/show?uid=124527) 开long long
by doughty @ 2019-07-31 12:38:39


@[doughty](/space/show?uid=59824) ok
by leoair @ 2019-07-31 13:25:14


|