結果
| 問題 |
No.2408 Lakes and Fish
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-05-04 23:46:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,227 bytes |
| コンパイル時間 | 1,922 ms |
| コンパイル使用メモリ | 196,584 KB |
| 最終ジャッジ日時 | 2025-02-21 10:56:01 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 RE * 17 |
コンパイルメッセージ
main.cpp:7:18: warning: overflow in conversion from ‘double’ to ‘long long int’ changes value from ‘1.0e+19’ to ‘9223372036854775807’ [-Woverflow]
7 | const ll INF=1e19+5;
| ~~~~^~
ソースコード
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll N=2e5+5;
const ll INF=1e19+5;
void solve(){
ll n,m; cin>>n>>m;
ll arr[N];
ll tree[n];
memset(arr,0,sizeof(arr));
for(int i=0;i<n;i++){
cin>>tree[i];
arr[tree[i]]=1;
}
vector<pair<ll,pair<ll,ll>>>v(n);
for(int i=0;i<n;i++){
cin>>v[i].first>>v[i].second.first>>v[i].second.second;
}
ll sum=0;
for(int i=0;i<n;i++){
if(arr[v[i].first]==1){
sum+=v[i].second.second;
// cout<<v[i].second.second;
}
else{
ll l,r;
l=lower_bound(tree,tree+n,v[i].first)-tree;
r=upper_bound(tree,tree+n,v[i].first)-tree-1;
ll dist=min(abs(v[i].first-tree[l]),abs(v[i].first-tree[r]));
if(dist<v[i].second.second-v[i].second.first){
sum+=v[i].second.second-dist;
// cout<<v[i].second.second-dist<<endl;
}
else{
sum+=v[i].second.first;
// cout<<v[i].second.first<<endl;
}
}
}
cout<<sum<<endl;
}
int main(){
ll tc; tc=1;
while(tc--){
solve();
}
}
vjudge1