标签:include frame stream algorithm ons wap HERE ios fan
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1609 Accepted Submission(s): 591
#include <stdio.h> #include <iostream> #include <queue> #include <vector> #include <algorithm> #include <string.h> #define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define ll long long #define maxx 100009 using namespace std; int n, a[maxx], c[maxx]; int x, y; struct node { int v; int order; }in[maxx]; int lowbit(int x) { return x & (-x); } void updata(int x, int val) { for (int i = x; i <= n; i += lowbit(i)) { c[i] += val; } } int getsum(int end) { int sum = 0; for (int i = end; i > 0; i -= lowbit(i)) { sum += c[i]; } return sum; } bool cmp(const node &a, const node &b) { if (a.v != b.v) return a.v < b.v; return a.order < b.order; }//这个地方必须排order int main() { fio; while (cin>>n>>x>>y) { memset(c, 0, sizeof c); memset(a, 0, sizeof a); memset(in, 0, sizeof in); for (int i = 1; i <= n; i++) { cin >> in[i].v; in[i].order = i; } sort(in + 1, in + n + 1, cmp); for (int i = 1; i <= n; i++) { a[in[i].order] = i; } ll sum = 0,ans; for (int i = 1; i <= n; i++) { updata(a[i], 1); sum += i - getsum(a[i]); } ans = sum * min(x, y); cout << ans << endl; } //getchar(); return 0; }
标签:include frame stream algorithm ons wap HERE ios fan
原文地址:https://www.cnblogs.com/the-way-of-cas/p/9380748.html