Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求教。。。以下代码G++ wa C++ac。。。。

Posted by SCSE10_Candybox at 2011-12-15 00:17:57 on Problem 4014
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
struct DICE
{
       int id;
       long long l,r;
       long long a;
}dice[2000],*di[2000];
int n;
bool cmp(DICE* a,DICE* b)
{
     return a->a<b->a;
}
int main()
{
    cin>>n;
    long long sum=0;
    memset(dice,0,sizeof(dice));
    for (int i=0;i<n;++i)
    {
        dice[i].id=i;
        cin>>dice[i].a;
        sum+=dice[i].a;
        di[i]=&dice[i];
    }
    sort(di,di+n,cmp);
    double E=0.0;
    for (int i=0;i<n;++i)
    {
        di[i]->r=sum;
        sum-=di[i]->a;
        di[i]->l=sum+1;
        E+=((double)(di[i]->r+di[i]->l))/2.0;
    }
    printf("%.5lf\n",E);
    for (int i=0;i<n;++i)
    {
        printf("%d",dice[i].l);
        for (int j=dice[i].l+1;j<=dice[i].r;++j) printf(" %d",j);
        printf("\n");
    }
    //system("pause");
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator