結果

問題 No.1650 Moving Coins
ユーザー tailstails
提出日時 2021-08-21 23:41:54
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,481 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 33,280 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-04-23 14:29:28
合計ジャッジ時間 5,218 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 7 ms
6,944 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 7 ms
5,504 KB
testcase_17 AC 6 ms
5,504 KB
testcase_18 AC 7 ms
6,016 KB
testcase_19 AC 7 ms
7,040 KB
testcase_20 AC 8 ms
7,296 KB
testcase_21 AC 8 ms
7,296 KB
testcase_22 AC 8 ms
7,296 KB
testcase_23 AC 8 ms
7,168 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 5 ms
5,760 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:16:1: warning: return type defaults to 'int' [-Wimplicit-int]
   16 | main(){
      | ^~~~
main.c: In function 'main':
main.c:27:20: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   27 |                 m+=abs(a[i]-b[i]);
      |                    ^~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
  +++ |+#include <stdlib.h>
    1 | #pragma GCC optimize("Ofast")
main.c:84:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   84 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:85:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   85 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

char*mmap();
char wbuf[1<<25];

#define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define WTHI(v) {long _z=v,_n=0,_d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;}
#define WTLO(v) {long _z=v,_n=8,_d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;}
#define wt(v) WTHI(v)
#define rep(v,e) for(long v=0;v<e;++v)
#define rrep(v,e) for(long v=e;--v>=0;)

int a[200000],b[200000];

main(){
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd(n);
	long m=0;
	rep(i,n){
		rd(ai);
		a[i]=ai;
	}
	rep(i,n){
		rd(bi);
		b[i]=bi;
		m+=abs(a[i]-b[i]);
	}
	char*wp=wbuf;
	wt(m);
	*wp++='\n';
	rep(i,n){
		long z=a[i]-b[i];
		if(z>0){
			long i1=i+1;
			if(i1>=100000){
				long d=' '|'L'<<8;
				rep(j,6){
					d=d<<8|i1%10+0x30;
					i1/=10;
				}
				rep(j,z){
					*(long*)wp=d;
					wp+=8;
					*wp++='\n';
				}
			}else{
				long d=' '|'L'<<8|'\n'<<16;
				long k=3;
				while(++k,d=d<<8|0x30|i1%10,i1/=10);
				rep(j,z){
					*(long*)wp=d;
					wp+=k;
				}
			}
		}
	}
	rrep(i,n){
		long z=b[i]-a[i];
		if(z>0){
			long i1=i+1;
			if(i1>=100000){
				long d=' '|'R'<<8;
				rep(j,6){
					d=d<<8|i1%10+0x30;
					i1/=10;
				}
				rep(j,z){
					*(long*)wp=d;
					wp+=8;
					*wp++='\n';
				}
			}else{
				long d=' '|'R'<<8|'\n'<<16;
				long k=3;
				while(++k,d=d<<8|0x30|i1%10,i1/=10);
				rep(j,z){
					*(long*)wp=d;
					wp+=k;
				}
			}
		}
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0