結果
| 問題 | No.1904 Never giving up! |
| コンテスト | |
| ユーザー |
y f
|
| 提出日時 | 2022-04-18 16:19:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,177 bytes |
| 記録 | |
| コンパイル時間 | 760 ms |
| コンパイル使用メモリ | 69,120 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-29 11:34:40 |
| 合計ジャッジ時間 | 1,238 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | WA * 9 |
ソースコード
#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;
}
y f