- #include
- using namespace std;
- int n;
- int const N = 1e5 + 10;
- int arr[N];
- int main()
- {
- cin >> n;
- long long ans = 0;
- long long w = 0;
- for (int i = 1;i <= n;i++)
- {
- long long x;
- cin >> x;
- if (i > 1)
- {
- ans += w * x;
- }
- w += x;
- }
- cout << ans << endl;
- return 0;
- }
- #include
- using namespace std;
- #include
- #include
- int n;
- struct person
- {
- int n1;
- int n2;
- int n3;
- int r;
- int a;
- };
- person arr[1010];
-
- bool cmp(person p1, person p2)
- {
- if (p1.r == p2.r)
- {
- return p1.a < p2.a;
- }
- return p1.r < p2.r;
- }
- int main()
- {
- cin >> n;
- int maxx = 0;
- int pos;
- for (int i = 1;i <= n;i++)
- {
- cin >> arr[i].n1 >> arr[i].n2 >> arr[i].n3;
- arr[i].r = arr[i].n1 + arr[i].n2 + arr[i].n3;
- arr[i].a = arr[i].n1 + arr[i].n2;
- /*if (arr[i].n3 > maxx)
- {
- maxx = arr[i].n3;
- pos = i;
- }
- else if (arr[i].n3 == maxx)
- {
- if (arr[i].n1 + arr[i].n2 > arr[pos].n1 + arr[pos].n2)
- {
- pos = i;
- }
- }*/
- }
- /*maxx = arr[pos].n1 + arr[pos].n2;
- arr[pos].n1 = 0;
- arr[pos].n2 = 0;
- arr[pos].n3 = 0;
- arr[pos].r = 0;
- arr[pos].a = 0;*/
- sort(arr + 1, arr + 1 + n,cmp);
-
- long long ans = 0;
- long long cnt = 0;
- for (int i = 1;i <= n;i++)
- {
- ans += cnt + arr[i].n1 + arr[i].n2;
- cnt += arr[i].n1 + arr[i].n2 + arr[i].n3;
- }
- //ans += ( cnt + maxx );
- cout << ans << endl;
- return 0;
- }