結果

問題 No.2408 Lakes and Fish
ユーザー umezoumezo
提出日時 2023-08-11 21:39:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 744 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 203,280 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-29 12:30:31
合計ジャッジ時間 3,983 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 AC 47 ms
6,400 KB
testcase_05 AC 48 ms
6,272 KB
testcase_06 AC 48 ms
6,400 KB
testcase_07 AC 58 ms
6,400 KB
testcase_08 AC 61 ms
6,528 KB
testcase_09 AC 59 ms
6,272 KB
testcase_10 AC 59 ms
6,400 KB
testcase_11 AC 31 ms
5,376 KB
testcase_12 AC 43 ms
5,504 KB
testcase_13 AC 13 ms
5,376 KB
testcase_14 AC 25 ms
5,376 KB
testcase_15 AC 49 ms
5,632 KB
testcase_16 AC 17 ms
5,376 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 28 ms
5,376 KB
testcase_19 AC 45 ms
5,760 KB
testcase_20 AC 43 ms
5,504 KB
testcase_21 AC 47 ms
5,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,m;
  cin>>n>>m;
  vector<ll> L(n);
  rep(i,n) cin>>L[i];
  vector<ll> F(m),B(m),W(m);
  rep(i,m) cin>>F[i]>>B[i]>>W[i];
  
  ll ans=0;
  rep(i,m){
    auto t=lower_bound(ALL(L),F[i])-L.begin();
    ll mi=1e9+7;
    if(t!=n){
      if(L[t]==F[i]){
        ans+=W[i];
        continue;
      }
      ans+=B[i];
      mi=min(mi,L[t]-F[i]);
    }
    else ans+=B[i];
    if(t!=0){
      t--;
      mi=min(mi,F[i]-L[t]);
    }
    if(W[i]-B[i]>mi){
      ans+=W[i]-B[i]-mi;
    } 
  }
  cout<<ans<<endl;
    
  return 0;
}
0