結果

問題 No.1904 Never giving up!
ユーザー y fy f
提出日時 2022-04-18 16:19:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,177 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 68,744 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 12:34:59
合計ジャッジ時間 1,274 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<array>
#include<vector>
using namespace std;

unsigned long long  fact(int  n)
{
    unsigned long long  ret = 1;
    while (n > 1)
        ret *= n--;
    return ret;
}

int main(){
    int  n;
    cin >> n;
    vector<int> array(n);
    for(int i=0;i<n;i++){
        cin >> array[i];
    }
    for(int i=n-1;i>=0;i--){
        int max = 0;
        int index=0;
        int tmp=0;
        for(int j=i;j>=0;j--){
            if(array[j]>max){
                max=array[j];
                index=j;
            }
        }
        tmp = array[i];
        array[i] = max;
        array[index]=tmp;
    }
    int count = 1;
    unsigned long long ans = 1;
    int flag = 0;
    unsigned long long  all=fact(n);
    while(flag<n-1){
        for(int i=flag;i<n-1;i++){
            if(array[i]==array[i+1]){
                count++;
                if(i==n-2){
                  ans*=fact(count);
                  flag=i+1;        
                  break;  
                } 
            }
            else{
                ans *=fact(count);
                flag=i+1;
                count = 1;
            }
        }
    }
    cout << all <<endl;
}
0