AtCoder Beginner Contest 057

Submission #1201109

Source codeソースコード

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X=X;}
#define TF(f) {f=f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 50
#define MAX 10

    int N,A,B;
    priority_queue<ll> v;
    vector<ll> mo;
    ll temp=0,id=0,mem,yui=1,sum=0;
    long double ans,av=0;
    int TR[1000]={0},bf;
    ll C[200][200];
    bool fir=true;

void Conb(int N){
    for(int i=0;i<=N;i++){
        for(int j=0;j<=i;j++){
            if(j==0||j==i)C[i][j]=1;
            else{
                C[i][j]=C[i-1][j-1]+C[i-1][j];
            }
        }
    }
}



int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>A>>B;
    REP(i,N){
        cin>>temp;
        v.push(temp);
        mo.push_back(temp);
    }
    sort(mo.begin(),mo.end(),greater<ll>());
        ll bu=0;
        for(int j=A;j>0;j--){
            bu+=v.top();
            v.pop();
        }
         av=(double)bu/(double)A;

        int count=0;
        int lo=0;
        Conb(N);
        yui=0;
        REP(i,N){
            if(mo[i]==mo[A-1]){
                count++;
                if(i<=A-1)lo++;
            }
DEB(count)DEB(lo)DEB(mo[i])DEB(mo[A-1])END
        }
        if(mo[0]==mo[A-1]){
                FOR(i,A,B+1){
                yui+=C[count][i];
                }
        }else{
            yui=C[count][lo];
        }

    cout<<fixed<<av<<setprecision(10)<<endl<<yui<<endl;
}
//ABC057 Maximum Average Sets

Submission

Task問題 D - Maximum Average Sets
User nameユーザ名 Nafmo
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 1985 Byte
File nameファイル名
Exec time実行時間 1 ms
Memory usageメモリ使用量 384 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt
All 400 / 400 sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt,subtask_1_1.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt,subtask_1_2.txt,subtask_1_3.txt,subtask_1_4.txt,subtask_1_5.txt,subtask_1_6.txt,subtask_1_7.txt,subtask_1_8.txt,subtask_1_9.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 384 KB
subtask_1_1.txt AC 1 ms 256 KB
subtask_1_10.txt AC 1 ms 384 KB
subtask_1_11.txt AC 1 ms 384 KB
subtask_1_12.txt AC 1 ms 384 KB
subtask_1_13.txt AC 1 ms 384 KB
subtask_1_14.txt AC 1 ms 384 KB
subtask_1_15.txt AC 1 ms 384 KB
subtask_1_2.txt AC 1 ms 256 KB
subtask_1_3.txt AC 1 ms 384 KB
subtask_1_4.txt AC 1 ms 384 KB
subtask_1_5.txt AC 1 ms 384 KB
subtask_1_6.txt AC 1 ms 384 KB
subtask_1_7.txt AC 1 ms 384 KB
subtask_1_8.txt AC 1 ms 384 KB
subtask_1_9.txt AC 1 ms 384 KB