1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
| #include<algorithm> #include<bitset> #include<complex> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<cmath> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> using namespace std;
#define re #define int long long #define LD double
class Quick_Input_Output{ private: static const int S=1<<21; #define tc() (A==B&&(B=(A=Rd)+fread(Rd,1,S,stdin),A==B)?EOF:*A++) char Rd[S],*A,*B; #define pc putchar public: #undef gc #define gc getchar inline int read(){ int res=0,f=1;char ch=gc(); while(ch<'0'ch>'9'){if(ch=='-') f=-1;ch=gc();} while(ch>='0'&&ch<='9') res=res*10+ch-'0',ch=gc(); return res*f; } inline void write(int x){ if(x<0) pc('-'),x=-x; if(x<10) pc(x+'0'); else write(x/10),pc(x%10+'0'); } #undef gc #undef pc }I; #define File freopen("tmp.in","r",stdin);freopen("tmp.out","w",stdout);
struct node{ int a,b; }f[100010]; inline int cmp(node x,node y){return x.a<y.a(x.a==y.a&&x.b<y.b);} class Array_Tree{ private: int c[1000010]; public: inline void add(int x,int y){for(;x<=1000000;x+=(x&(-x))) c[x]+=y;} inline int getsum(int x){re int s=0;for(;x>=1;x-=(x&(-x))) s+=c[x];return s;} inline int query(int l,int r){return getsum(r)-getsum(l);} }T; class Solve{ private: int n,l,c,v[100010],ans,Max; public: inline bool init(){ n=I.read();l=I.read();c=I.read(); for(int i=1;i<=n;i++) v[i]=I.read(),Max=max(Max,v[i]); for(int i=1;i<=n;i++) f[i].a=v[i]*l/Max,f[i].b=v[i]*l%Max; } inline void solve(){ sort(f+1,f+n+1,cmp); for(int sum=0,i=1;i<=n;i++){ ans+=(f[i].a*(i-1)-sum)-T.query(f[i].b,1000000); sum+=f[i].a; if(f[i].b>0) T.add(f[i].b,1); } I.write(ans);putchar('\n'); } }S; signed main(){
S.init(); S.solve(); }
|