Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提出 二分探索 #139

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

提出 二分探索 #139

wants to merge 3 commits into from

Conversation

rose539
Copy link

@rose539 rose539 commented Jun 27, 2022

No description provided.

Copy link

@nanashima nanashima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apple.c spear.c works.c が正しく動いていません.

src/apple.c Outdated
for(int j = 0; j < n; j++){
sum += A[j];
}
return sum;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

初期値が大きすぎて,最悪桁あふれします.改善してください.

src/spear.c Outdated
for(int j = 0; j < n; j++){
sum += A[j];
}
return sum;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここもです.

}

//人の入れ替わりがk-1回起こるようにする
int p(int m){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原因までは特定してないですが,資料中のケースでも正しく動いていないのでは?

@rose539
Copy link
Author

rose539 commented Jul 4, 2022

二分探索 再提出

Copy link

@nanashima nanashima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spearは境界値で正しい答えを返しません.
worksはほとんどのランダムケースで正しい答えを返していないです.(大きめの解を出しています)

src/spear.c Outdated


lb = 0;
ub = m(A);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

初期値が不適切です.

src/works.c Outdated
int people = 1;
for(int a = 0; a < n-1; a++){
if(A[a] + A[a+1] <= m){
A[a+1] = A[a] + A[a+1];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aに直接操作するのはあまり良い方法ではないです.
何度もpを呼ぶわけなので.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants