Submission #00052
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #include<bits/stdc++.h> using namespace std; int main(){ int n;cin>>n; bool y= false ; int h; string s[n],a[n]; for ( int i=0;i<n;i++){ cin>>s[i]>>a[i]; string f2; for ( int j=0;j<40-a[i].size();j++){ f2+= '0' ; } f2+=a[i]; a[i]=f2; if (s[i]== "gousuper" ){ y= true ; h=i; } } if (y){ int k=0; for ( int i=0;i<n;i++){ if (a[i]>a[h]){ k++; } } if (k>n/2){ vector<pair<string,string>>v(n); for ( int i=0;i<n;i++){ v[i].first=a[i]; v[i].second=s[i]; } sort(v.begin(),v.end()); for ( int i=0;i<n;i++){ cout<<i+1<< " " <<v[i].second<< "\n" ; } } else { vector<pair<string,string>>v(n); for ( int i=0;i<n;i++){ v[i].first=a[i]; v[i].second=s[i]; } sort(v.rbegin(),v.rend()); for ( int i=0;i<n;i++){ cout<<i+1<< " " <<v[i].second<< "\n" ; } } } else { vector<pair<string,string>>v(n); for ( int i=0;i<n;i++){ v[i].first=a[i]; v[i].second=s[i]; } sort(v.rbegin(),v.rend()); for ( int i=0;i<n;i++){ cout<<i+1<< " " <<v[i].second<< "\n" ; } } } |
ステータス
項目 | データ |
---|---|
問題 | 0018 - GouSorter2 |
ユーザー名 | ei2326 |
投稿日時 | 2023-11-13 12:06:23 |
言語 | C++17 |
状態 | Accepted |
得点 | 50 |
ソースコード長 | 1411 Byte |
最大実行時間 | 29 ms |
最大メモリ使用量 | 696 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 50 / 50 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in-01.txt | AC | 21 ms | 600 KB |
1
|
in-02.txt | AC | 18 ms | 696 KB |
1
|
in-03.txt | AC | 25 ms | 656 KB |
1
|
in-04.txt | AC | 20 ms | 588 KB |
1
|
in-05.txt | AC | 22 ms | 552 KB |
1
|
in-06.txt | AC | 19 ms | 656 KB |
1
|
in-07.txt | AC | 29 ms | 632 KB |
1
|
in-08.txt | AC | 28 ms | 596 KB |
1
|
in-09.txt | AC | 27 ms | 568 KB |
1
|
in-10.txt | AC | 23 ms | 540 KB |
1
|