結果

問題 No.2408 Lakes and Fish
ユーザー nystnyst
提出日時 2023-08-11 22:20:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,159 bytes
コンパイル時間 3,513 ms
コンパイル使用メモリ 191,704 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 13:20:20
合計ジャッジ時間 7,013 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 147 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cmath>
#include <bitset>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <tuple>
#include <atcoder/all>
#include <sstream> // std::stringstream
#include <regex>
#include <fstream>
using namespace atcoder;
using mint = modint998244353;
//using mint = modint1000000007;
using namespace std;
using ll = long long;
static const double pi = 3.141592653589793;
const int INF = (1 << 29);
const ll mod = 998244353;
// ifstream ifs(""); ファイルはワークスペースのトップにおく

int main() {
    int n,m;
    cin >> n >> m;

    vector<int> L(n);
    for(int i=0;i<n;i++) cin >> L[i];



    ll ans = 0;
    while(m--){
        int f,b,w;
        cin >> f >> b >> w;
        int lb = lower_bound(L.begin(),L.end(),f)-L.begin();
        int ub = lb + 1;
        if(lb==n) lb--;
        if(ub==n) ub--;
        int cost = min(abs(f-L[lb]),abs(f-L[ub]));
        if(cost == 0){ //湖にいる
            ans += w;
        }else{ //陸にいる
            ans += max(w-cost,b);
        }
    }
    cout << ans << endl;
} 
0