結果

問題 No.938 賢人を探せ
ユーザー ngtkanangtkana
提出日時 2020-03-06 17:13:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 4,996 ms
コンパイル使用メモリ 190,500 KB
実行使用メモリ 5,940 KB
最終ジャッジ日時 2023-08-21 03:44:07
合計ジャッジ時間 6,801 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
5,940 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 14 ms
4,380 KB
testcase_09 AC 14 ms
4,384 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 19 ms
4,432 KB
testcase_12 AC 19 ms
4,444 KB
testcase_13 AC 19 ms
4,396 KB
testcase_14 AC 19 ms
4,588 KB
testcase_15 AC 18 ms
4,476 KB
testcase_16 AC 19 ms
4,584 KB
testcase_17 AC 19 ms
4,436 KB
testcase_18 AC 19 ms
4,376 KB
testcase_19 AC 19 ms
4,432 KB
testcase_20 AC 19 ms
4,468 KB
testcase_21 AC 19 ms
4,500 KB
testcase_22 AC 51 ms
5,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
int main(){
    int n;std::cin>>n;
    std::vector<std::string>a(n);
    std::vector<std::pair<std::string,int>>b(n);
    for(int i=0;i<n;i++){
        std::cin>>a.at(i)>>b.at(i).first;
        b.at(i).second=i;
    }
    std::sort(a.begin(),a.end());
    std::sort(b.begin(),b.end());
    std::vector<std::pair<int,std::string>>ans;
    for(int i=0,j=0;j<n;j++){
        if(j&&b.at(j-1).first==b.at(j).first)continue;
        for(;i<n&&a.at(i)<b.at(j).first;i++);
        if(i==n||b.at(j).first<a.at(i)){
            ans.emplace_back(b.at(j).second,b.at(j).first);
        }
    }
    std::sort(ans.begin(),ans.end());
    for(auto&&p:ans){
        std::cout<<p.second<<std::endl;
    }
}

0