-
Notifications
You must be signed in to change notification settings - Fork 171
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
提出 #169
base: main
Are you sure you want to change the base?
提出 #169
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,32 @@ int n; | |
int k; | ||
int A[100000]; | ||
|
||
int p(int x){ | ||
int i,sum; | ||
sum=0; | ||
for (i=0;i<n;i++){ | ||
sum +=A[i]/x; | ||
} | ||
return sum >= k; | ||
} | ||
|
||
int main(){ | ||
int i, lb, ub; | ||
scanf("%d%d", &n, &k); | ||
for(i = 0; i < n; i++){ | ||
scanf("%d", &A[i]); | ||
} | ||
|
||
|
||
lb=0; | ||
ub=1000000000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 初期値が不適切です. |
||
while(ub-lb>1){ | ||
int mid =(lb +ub/2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここもです. |
||
if(p(mid)){ | ||
ub=mid; | ||
} | ||
else { | ||
lb=mid; | ||
} | ||
} | ||
printf("%d\n", ub); | ||
return 0; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,41 @@ int n; | |
int k; | ||
int A[100000]; | ||
|
||
int p(int x){ | ||
int i,j,sum; | ||
sum=0; | ||
j=1; | ||
for(i=0;i<n;i++){ | ||
if(A[i]>x)return 0; | ||
if(j+A[i]<=x){ | ||
j+=A[i]; | ||
} | ||
else{ | ||
j++; | ||
sum=A[i]; | ||
} | ||
} | ||
return j<=k; | ||
} | ||
|
||
|
||
int main(){ | ||
int i, lb, ub; | ||
scanf("%d%d", &n, &k); | ||
for(i = 0; i < n; i++){ | ||
scanf("%d", &A[i]); | ||
} | ||
|
||
|
||
lb=0; | ||
ub=1000000000; | ||
while(ub-lb>1){ | ||
int mid =(lb +ub/2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここもです. |
||
if(p(mid)){ | ||
ub=mid; | ||
} | ||
else { | ||
lb=mid; | ||
} | ||
} | ||
printf("%d\n", ub); | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
正しくないです.