水题
#include <cstdio> #include <algorithm> using namespace std; const int N = 1010; struct node{ int s, f; inline bool operator < (const node &o) const{ return s < o.s; } } a[N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i].s); a[i].f = i + 1; } sort(a, a + n); int sum = 0; for (int i = 0; i < n; i++) sum += i * a[n - 1 - i].s + 1; printf("%d ", sum); for (int i = n - 1; i >= 0; i--) printf("%d ", a[i].f); return 0; }