提交时间:2022-07-20 12:15:16
运行 ID: 52931
#include <bits/stdc++.h> using namespace std; int n,a,b,p,sum,u[25]; string w; int read() { char ch = getchar(); int ret = 0,f = 1; while(ch == ' ' || ch == '\n') ch = getchar(); while(ch == '-') { f *= -1; ch = getchar(); } while('0' <= ch && ch <= '9') { ret = ret * 10 + ch - '0'; ch = getchar(); } return f * ret; } int main() { n = read(),a = read(),b = read(); for(int i = 1; i <= n; i++) scanf("%d",&u[i]); for(int i = 1; i <= n; i++) { if(u[i] == i) continue; for(int j = i + 1; j <= n; j++) if(u[j] == i) swap(u[i],u[j]); sum += a; } printf("%d\n",sum); return 0; }