結果

問題 No.2408 Lakes and Fish
ユーザー planesplanes
提出日時 2023-11-14 11:09:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 1,679 ms
コンパイル使用メモリ 170,344 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-14 11:09:07
合計ジャッジ時間 5,234 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 46 ms
6,676 KB
testcase_05 AC 46 ms
6,676 KB
testcase_06 AC 47 ms
6,676 KB
testcase_07 AC 58 ms
6,676 KB
testcase_08 AC 57 ms
6,676 KB
testcase_09 AC 57 ms
6,676 KB
testcase_10 AC 57 ms
6,676 KB
testcase_11 AC 31 ms
6,676 KB
testcase_12 AC 41 ms
6,676 KB
testcase_13 AC 12 ms
6,676 KB
testcase_14 AC 24 ms
6,676 KB
testcase_15 AC 46 ms
6,676 KB
testcase_16 AC 16 ms
6,676 KB
testcase_17 AC 13 ms
6,676 KB
testcase_18 AC 27 ms
6,676 KB
testcase_19 AC 45 ms
6,676 KB
testcase_20 AC 42 ms
6,676 KB
testcase_21 AC 46 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);

ll N,M;cin>>N>>M;
vector<ll> L(N);
for(ll i=0;i<N;i++) cin>>L[i];

vector<ll> F(M),B(M),W(M);
for(ll i=0;i<M;i++) cin>>F[i]>>B[i]>>W[i];

ll ans=0;
for(ll i=0;i<M;i++) {
  ll ind=lower_bound(all(L),F[i])-L.begin();
  ll ma=-INF;
  if(ind>0) {
    ma=max(ma,max(B[i],W[i]-(F[i]-L[ind-1])));
  }
  if(ind<L.size()) {
    ma=max(ma,max(B[i],W[i]-(L[ind]-F[i])));
  }
  ans+=ma;
}

cout<<ans<<endl;
}
0