結果

問題 No.489 株に挑戦
コンテスト
ユーザー 👑 tails
提出日時 2024-05-01 11:50:57
言語 C90
(gcc 12.3.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 915 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,157 ms
コンパイル使用メモリ 26,976 KB
最終ジャッジ日時 2025-11-05 09:39:17
合計ジャッジ時間 2,042 ms
ジャッジサーバーID
(参考情報)
judge1 / judge7
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'f1':
main.c:23:13: error: expected ';' before 'i'
   23 |         rep(i,n){
      |             ^
main.c:7:32: note: in definition of macro 'rep'
    7 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                ^
main.c:23:13: error: 'i' undeclared (first use in this function)
   23 |         rep(i,n){
      |             ^
main.c:7:36: note: in definition of macro 'rep'
    7 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                    ^
main.c:23:13: note: each undeclared identifier is reported only once for each function it appears in
   23 |         rep(i,n){
      |             ^
main.c:7:36: note: in definition of macro 'rep'
    7 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                    ^
main.c: In function 'f2':
main.c:29:13: error: expected ';' before 'i'
   29 |         rep(i,n+d){
      |             ^
main.c:7:32: note: in definition of macro 'rep'
    7 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                ^
main.c:29:13: error: 'i' undeclared (first use in this function)
   29 |         rep(i,n+d){
      |             ^
main.c:7:36: note: in definition of macro 'rep'
    7 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                    ^

ソースコード

diff #
raw source code

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) ({ulong _z=v;do*--wp=_z%10+48;while(_z/=10);})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)

typedef unsigned long ulong;

char wbuf[64];
int n,d,k;
int x[100000];
int s[100000];
int r,w;
int b=0,j=0,h=0;

void f1(){
	rd_init();
	n=rd();
	d=rd();
	k=rd();
	rep(i,n){
		x[i]=rd();
	}
}

void f2(){
	rep(i,n+d){
		if(r<w&&s[r]<i-d){
			++r;
		}
		if(i<n){
			while(r<w&&x[s[w-1]]<x[i]){
				--w;
			}
			s[w++]=i;
		}
		if(i>=d&&b<x[s[r]]-x[i-d]){
			b=x[h=s[r]]-x[j=i-d];
		}
	}
}

void f3(){
	char wbuf[64],*wp=wbuf+sizeof wbuf;
	if(b){
		wt(h);
		*--wp=' ';
		wt(j);
		*--wp='\n';
		wt((long)k*b);
	}else{
		*--wp='0';
	}
	write(1,wp,wbuf+sizeof wbuf-wp);
}

int main(){
	f1();
	f2();
	f3();
	_exit(0);
}
0