結果

問題 No.586 ダブルブッキング
ユーザー zaichu
提出日時 2017-11-03 22:26:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 1,585 ms
コンパイル使用メモリ 168,368 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 15:53:49
合計ジャッジ時間 2,066 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long gcd(long long x, long long y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

long long lcm(long long x, long long y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    int P1, P2;
    cin >> P1 >> P2;
    int N;
    cin >> N;
    vector<int> R(1000, 0);
    for (int i = 0; i < N; i++)
    {
        int r;
        cin >> r;
        R[r]++;
    }
    long ans = 0;
    for (int i = 0; i < 1000; i++)
    {
        if (R[i] > 1)
        {
            ans += (P1 + P2) * (R[i] - 1);
        }
    }
    cout << ans << endl;
}
0