結果

問題 No.1416 ショッピングモール
ユーザー tsuishitsuishi
提出日時 2021-04-08 16:20:17
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 2,318 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 30,832 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 00:24:15
合計ジャッジ時間 3,298 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 RE -
testcase_16 AC 2 ms
4,380 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
extern int getchar_unlocked(void);
extern int putchar_unlocked(int);
#define gc(d)	(d)=getchar_unlocked()
#define	pc(d) putchar_unlocked(d)
#define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0)
#define MAX(a,b)	((a)>(b)?(a):(b))
#define MIN(a,b)	((a)<(b)?(a):(b))
#define REP(a,b) for(int a=0;a<(int)(b);++a)
#define REP1(a,b) for(int a=1;a<=(int)(b);++a)
static char *GETWORD(char* str) {char c;char *cp;cp=&str[0];gc(c);while(c!=EOF){if((c==' ')||(c=='\n'))break;*cp++=c;gc(c);}*cp='\0';return &str[0];}
#define GETLINE(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0)
#define mygc(c) (c)=getchar()
static void read1(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
static void read2(int *x, int *y){read1(x);read1(y);}
#define INPUT(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0)
#define REP(a,b) for(int a=0;a<(int)(b);++a)
#define lolong long long
static int GETLINEINT(void) {char s[34];GETLINE(s);return atoi(s);}
static int GETWORDINT(void) {char s[34];GETWORD(s);return atoi(s);}
static int cmpint_asc(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
static int cmpint_desc(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
#define	ull	unsigned long long
// *********************
ull inl()   // 整数の入力(負数に対応)
{
	ull n = 0ULL;
	int c;
	gc(c);
	do {
		n = 10 * n + (c & 0xf);
		gc(c);
	} while (c >= '0');
	return n;
}
void outl(ull n) {
	int i;
	char b[70];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}
int	clerk[5010];
// *********************
int main( void ) {
	int q;
	int	a;
	ull	cost = 0ULL;
	int	idx = 0;
	int	ms = 1;

	q = GETLINEINT();
	REP(i,q) {
		clerk[i] = GETWORDINT();
	}
	qsort( clerk, q, sizeof(clerk[0]) , cmpint_desc );
	for(int f = 0; idx < q ; f++) {
		REP(k, ms) {
			cost += (ull)(clerk[idx++] * f);
			if( idx >= q ) break;
		}
		ms *= 2;
	}
	outl( cost );
}
0