結果
問題 |
No.2408 Lakes and Fish
|
ユーザー |
![]() |
提出日時 | 2024-05-01 13:56:34 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,526 bytes |
コンパイル時間 | 3,981 ms |
コンパイル使用メモリ | 277,480 KB |
実行使用メモリ | 13,768 KB |
最終ジャッジ日時 | 2024-11-21 18:42:45 |
合計ジャッジ時間 | 21,055 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 19 |
コンパイルメッセージ
main.cpp: In function 'long long int solve(long long int, long long int, long long int*, long long int*, long long int*, long long int*, long long int)': main.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type] 54 | } | ^
ソースコード
#include<bits/stdc++.h> #define in cin>> #define out cout<< #define mau ios::sync_with_stdio(0); #define tidur cin.tie(0); #define ll long long using namespace std; ll best, totgain; ll binser(ll tree[], ll left, ll right, ll pos){ while (left <= right) { int m = left + (right - left) / 2; if (tree[m] == pos) return 1; if (tree[m] < pos) left = m + 1; else right = m - 1; } return 0; } ll count(ll n, ll m, ll pos[], ll dark[], ll light[], ll tree[], ll c){ ll s=0; for(ll i=0; i<m; i++){ if(binser(tree, tree[0], tree[n], pos[i])){ s+=light[i]; } else{ s+=dark[i]; } } return s-c; } ll solve(ll n, ll m, ll pos[], ll dark[], ll light[], ll tree[], ll c){ if(c>totgain){ return 0; } best=max(best, count(n, m, pos, dark, light, tree, c)); ll newposr[m+5]; for(ll i=0; i<m; i++){ newposr[i]=pos[i]+1; } solve(n, m, newposr, dark, light, tree, c+1); ll newposl[m+5]; for(ll i=0; i<m; i++){ newposl[i]=pos[i]-1; } solve(n, m, newposl, dark, light, tree, c+1); } int main(){ ll n, m; in n >> m; ll tree[n]={0}, pos[m]={0}, dark[m]={0}, light[m]={0}; for(ll i=0; i<n; i++){ in tree[i]; } sort(tree, tree+n); for(ll i=0; i<m; i++){ in pos[i] >> dark[i] >> light[i]; totgain+=light[i]-dark[i]; } solve(n, m, pos, dark, light, tree, 0); out best; }