結果
問題 | No.2408 Lakes and Fish |
ユーザー | vjudge1 |
提出日時 | 2024-05-04 23:51:56 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,679 bytes |
コンパイル時間 | 2,330 ms |
コンパイル使用メモリ | 203,368 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-05-04 23:52:03 |
合計ジャッジ時間 | 6,734 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 3 ms
5,376 KB |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | AC | 128 ms
8,064 KB |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
コンパイルメッセージ
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; | ~~~~^~ main.cpp: In function 'void solve()': main.cpp:53:73: warning: 'hi' may be used uninitialized [-Wmaybe-uninitialized] 53 | ll dist=min(abs(v[i].first-tree[low]),abs(v[i].first-tree[hi])); | ~~~~~~~^ main.cpp:31:20: note: 'hi' was declared here 31 | ll low,hi; | ^~ main.cpp:53:48: warning: 'low' may be used uninitialized [-Wmaybe-uninitialized] 53 | ll dist=min(abs(v[i].first-tree[low]),abs(v[i].first-tree[hi])); | ~~~~~~~~^ main.cpp:31:16: note: 'low' was declared here 31 | ll low,hi; | ^~~
ソースコード
#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=0,r=n-1; ll low,hi; while(l<=r){ ll mid=(l+r)/2; if(tree[i]<v[i].first){ l=mid+1; } else{ low=mid; r=mid-1; } } l=0,r=n-1; while(l<=r){ ll mid=(l+r)/2; if(tree[i]>v[i].first){ r=mid-1; } else{ hi=mid; l=mid+1; } } ll dist=min(abs(v[i].first-tree[low]),abs(v[i].first-tree[hi])); 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(); } }