Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created March 7, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/3f5454c1e3696f373376 to your computer and use it in GitHub Desktop.
Save ik11235/3f5454c1e3696f373376 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[])
{
int n;
cin>>n;
vector<int> t;
for(int i=0;i<n;i++)
{
int tmp;
cin>>tmp;
t.push_back(tmp);
}
sort(t.begin(),t.end());
long long int sum=0;
long long int time=0;
long long int pat=1;
int cnt=0;
for(int i=0;i<n;i++)
{
time+=t[i];
sum+=time;
if(i>0&&t[i]==t[i-1])
cnt++;
else
cnt=1;
pat*=cnt;
pat%=1000000007;
}
cout<<sum<<endl;
cout<<pat<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment