結果

問題 No.628 Tagの勢い
ユーザー kpinkcatkpinkcat
提出日時 2023-08-19 12:20:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,211 bytes
コンパイル時間 1,435 ms
コンパイル使用メモリ 117,616 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 12:20:23
合計ジャッジ時間 2,534 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘bool comp(std::pair<int, std::__cxx11::basic_string<char> >&, std::pair<int, std::__cxx11::basic_string<char> >&)’ 内:
main.cpp:18:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   18 | }
      | ^

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
#include<vector>
#include <utility>
using namespace std;

bool comp(pair<int, string> &a, pair<int, string> &b){
    if (a.first != b.first) return a.first > b.first;
    else if (a.second != b.second) return a.second < b.second;
}

int main()
{
    int n, num;
    cin >> n;
    vector<pair<int, string>> vec;
    for (int i = 0; i < n; i++){
        int m, s;
        cin >> num >> m >>s;
        for (int j = 0; j < m; j++){
            string tag;
            cin >> tag;
            int vs = vec.size();
            for (int k = 0; k < vs; k++){
                if (vec.at(k).second == tag){
                    vec.at(k).first += s;
                    break;
                }
                if (k == vec.size() - 1) vec.push_back(make_pair(s, tag));
            }
            if (vec.size() == 0) vec.push_back(make_pair(s, tag));
        }
    }
    sort(vec.begin(), vec.end(), comp);
        num = 0;
    for (auto x : vec){
        cout << x.second << " " << x.first << endl;
        num++;
        if (num == 10) break;
    }
}
0