Submission #2402

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
24022013-07-21 07:50:47alephnull지우개 (GA4_eraser)C++98
0 / 100
28 ms2568 KiB
#include <cstdio>
#include <algorithm>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vll::iterator vlli;
int main() {
int n;scanf("%d",&n);
vll a(n,0);
for(int i=0;i<n;i++){
long long tmp;
scanf("%lld",&tmp);a[i]=tmp;
}
sort(a.begin(),a.end());
vll psum(n,0);
psum[0]=a[0];
for(int i=1;i<n;i++)psum[i]=(psum[i-1]+a[i])%MOD;
vll ppsum(n,0);
for(int i=n-2;i>=0;i--){
vlli hi= upper_bound(a.begin(),a.end(),a[i]+1);
int idx=hi-a.begin()-1;
if(a[idx]==a[i])ppsum[i]=ppsum[i+1];
else{ppsum[i]=(ppsum[i+1]+(a[i]*((MOD+psum[n-1]-psum[idx-1])%MOD))%MOD)%MOD;}
}
ll ans=0;
for(int i=0;i<n;i++){
vlli hi= upper_bound(a.begin(),a.end(),a[i]+1);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...