結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tails
提出日時 2021-11-18 16:59:24
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 476 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 26,624 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-03-03 11:53:03
合計ジャッジ時間 4,791 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:11:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   11 | main(){
      | ^~~~
main.c: In function ‘main’:
main.c:30:9: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   30 |         printf("%d.%09d\n",z/1000000000,z%1000000000);
      |         ^~~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
  +++ |+#include <stdio.h>
    1 | #pragma GCC optimize("Ofast")
main.c:30:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   30 |         printf("%d.%09d\n",z/1000000000,z%1000000000);
      |         ^~~~~~
main.c:30:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:30:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
   30 |         printf("%d.%09d\n",z/1000000000,z%1000000000);
      |                 ~^         ~~~~~~~~~~~~
      |                  |          |
      |                  int        long int
      |                 %ld
main.c:30:23: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long int’ [-Wformat=]
   30 |         printf("%d.%09d\n",z/1000000000,z%1000000000);
      |                    ~~~^                 ~~~~~~~~~~~~
      |                       |                  |
      |                       int                long int
      |                    %09ld

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

char*mmap();

#define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define rep(v,e) for(long v=0;v<e;++v)

long l[200000];

main(){
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd(n);
	rep(i,n){
		rd(li);
		l[i]=li*1000000000;
	}
	rd(k);
	long z=0;
	for(long d=1l<<62;d;d>>=1){
		long t=z+d;
		long c=0;
		rep(i,n){
			c+=l[i]/t;
		}
		if(c>=k){
			z=t;
		}
	}
	printf("%d.%09d\n",z/1000000000,z%1000000000);
}
0