답안 #9609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9609 2014-09-28T07:36:57 Z eternalklaus Uniting (kriii2_U) C++
0 / 4
0 ms 1476 KB
#include <stdio.h>
 
int arr[100001];
 
int main()
{
    int n,i,j,index;
    int tmp;
    int ttmp;
    int sum=0;
    long long nu=1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        index=0;
        scanf("%d",&tmp);
        while(tmp>arr[index]&&index<i)
            index++;
        //index++자리에 인서트.
 
        for(j=i-1;j>=index;j--)
            arr[j+1]=arr[j];
        arr[index]=tmp;
 
    }
    for(i=0;i<n-1;i++)
    {
        sum+=arr[i]*arr[i+1];
        if(arr[i]!=arr[i+1])
            nu=nu*2;
         
        arr[i+1]=arr[i]+arr[i+1]; 
         
        ttmp=arr[i+1];
 
        //i+1에서 n까지 쏘팅!!!
 
        for(j=i+2;j<n;j++)
        {
            if(ttmp<arr[j])
                break;
        }
		index=j-1;
        for(j=i+2;j<=index;j++)
        {
            arr[j-1]=arr[j];
        }
        arr[index]=ttmp;
    }

    printf("%d",sum);
    //printf("%ld\n",nu%1000000007);
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 1476 KB Output is partially correct
2 Partially correct 0 ms 1476 KB Output is partially correct
3 Partially correct 0 ms 1476 KB Output is partially correct
4 Partially correct 0 ms 1476 KB Output is partially correct
5 Partially correct 0 ms 1476 KB Output is partially correct
6 Incorrect 0 ms 1476 KB Output isn't correct
7 Halted 0 ms 0 KB -