結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー tailstails
提出日時 2021-11-03 16:35:47
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 34,552 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-21 07:55:38
合計ジャッジ時間 8,212 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 13 ms
7,552 KB
testcase_18 AC 10 ms
6,272 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 13 ms
7,936 KB
testcase_22 AC 13 ms
7,936 KB
testcase_23 AC 13 ms
8,064 KB
testcase_24 AC 13 ms
7,936 KB
testcase_25 AC 14 ms
7,936 KB
testcase_26 AC 13 ms
7,936 KB
testcase_27 AC 13 ms
7,936 KB
testcase_28 AC 13 ms
7,936 KB
testcase_29 AC 13 ms
7,936 KB
testcase_30 AC 13 ms
7,936 KB
testcase_31 AC 13 ms
7,936 KB
testcase_32 AC 13 ms
7,936 KB
testcase_33 AC 13 ms
7,936 KB
testcase_34 AC 13 ms
7,936 KB
testcase_35 AC 13 ms
7,936 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:44:1: warning: return type defaults to 'int' [-Wimplicit-int]
   44 | main(){
      | ^~~~
main.c: In function 'main':
main.c:76:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   76 |         write(1,wbuf,n+1);
      |         ^~~~~
main.c:77:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   77 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

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 rd_signed(v) long v=0;{long _c,_s;_s=*rp=='-'&&++rp;while(_c=*rp++-48,_c>=0)v=v*10+_c;v=_s?-v:v;}

char wbuf[1<<25];

#define rep(v,e) for(long v=0;v<e;++v)
#define rep3(v,s,e) for(long v=s;v<e;++v)

unsigned a[200000];
unsigned x[200000];

void indirect_radix_sort_aux(unsigned*x,unsigned*y,int n){
	int c[256];
	for(int i=0;i<256;++i){
		c[i]=0;
	}
	for(int i=0;i<n;++i){
		++c[a[i]&255];
	}
	int t=0;
	for(int i=0;i<256;++i){
		int u=c[i];
		c[i]=t;
		t+=u;
	}
	for(int i=0;i<n;++i){
		y[c[a[x[i]]&255]++]=x[i];
		a[x[i]]>>=8;
	}
}

void indirect_radix_sort(unsigned*x,int n){
	static unsigned y[200000];
	indirect_radix_sort_aux(x,y,n);
	indirect_radix_sort_aux(y,x,n);
	indirect_radix_sort_aux(x,y,n);
	indirect_radix_sort_aux(y,x,n);
}

main(){
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd(n);
	rd(k);
	rep(i,n){
		rd_signed(ai);
		a[i]=ai+(1u<<31);
	}
	rep(i,n){
		rd_signed(bi);
		a[i]-=bi;
	}
	rep(i,n){
		x[i]=i;
	}
	indirect_radix_sort(x,n);
	if(k*2<n){
		rep(i,n){
			wbuf[i]='B';
		}
		rep3(i,n-k,n){
			wbuf[x[i]]='A';
		}
	}else{
		rep(i,n){
			wbuf[i]='A';
		}
		rep(i,n-k){
			wbuf[x[i]]='B';
		}
	}
	wbuf[n]='\n';
	write(1,wbuf,n+1);
	_exit(0);
}
0