結果
| 問題 |
No.2408 Lakes and Fish
|
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2023-08-11 21:33:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 754 bytes |
| コンパイル時間 | 2,078 ms |
| コンパイル使用メモリ | 200,496 KB |
| 最終ジャッジ日時 | 2025-02-16 01:07:08 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin>>n>>m;
vector<long long> l(n),f(m),b(m),w(m);
for (int i=0;i<n;i++) cin>>l[i];
for (int i=0;i<m;i++) cin>>f[i]>>b[i]>>w[i];
sort(l.begin(),l.end());
long long ans=0;
for (int i=0;i<m;i++) {
int idx=lower_bound(l.begin(),l.end(),f[i])-l.begin();
if (idx==n) idx--;
if (l[idx]==f[i]) {
ans+=w[i];
continue;
}
long long get=w[i]-abs(l[idx]-f[i]);
if (get>=b[i]) {
ans+=get;
continue;
}
if (idx>0) {
idx--;
long long get2=w[i]-abs(f[i]-l[idx]);
if (get2>=b[i]) {
ans+=get2;
continue;
}
}
ans+=b[i];
}
cout<<ans<<endl;
}
Today03