結果
問題 | No.631 Noelちゃんと電車旅行 |
ユーザー | tails |
提出日時 | 2018-01-05 23:16:02 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 102 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 986 ms |
コンパイル使用メモリ | 29,952 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-02 09:29:19 |
合計ジャッジ時間 | 3,753 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
6,816 KB |
testcase_01 | AC | 101 ms
6,820 KB |
testcase_02 | AC | 102 ms
6,820 KB |
testcase_03 | AC | 100 ms
6,820 KB |
testcase_04 | AC | 101 ms
6,816 KB |
testcase_05 | AC | 102 ms
6,816 KB |
testcase_06 | AC | 41 ms
6,820 KB |
testcase_07 | AC | 24 ms
6,816 KB |
testcase_08 | AC | 74 ms
6,816 KB |
testcase_09 | AC | 86 ms
6,816 KB |
testcase_10 | AC | 62 ms
6,820 KB |
testcase_11 | AC | 54 ms
6,816 KB |
testcase_12 | AC | 71 ms
6,816 KB |
testcase_13 | AC | 66 ms
6,816 KB |
testcase_14 | AC | 32 ms
6,816 KB |
testcase_15 | AC | 57 ms
6,820 KB |
testcase_16 | AC | 3 ms
6,820 KB |
testcase_17 | AC | 3 ms
6,820 KB |
testcase_18 | AC | 3 ms
6,816 KB |
testcase_19 | AC | 3 ms
6,816 KB |
testcase_20 | AC | 3 ms
6,820 KB |
コンパイルメッセージ
main.c:7:1: warning: data definition has no type or storage class 7 | n;m; | ^ main.c:7:1: warning: type defaults to 'int' in declaration of 'n' [-Wimplicit-int] main.c:7:3: warning: data definition has no type or storage class 7 | n;m; | ^ main.c:7:3: warning: type defaults to 'int' in declaration of 'm' [-Wimplicit-int] main.c:9:1: warning: return type defaults to 'int' [-Wimplicit-int] 9 | mk(i,a,b){ | ^~ main.c: In function 'mk': main.c:9:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:9:1: warning: type of 'a' defaults to 'int' [-Wimplicit-int] main.c:9:1: warning: type of 'b' defaults to 'int' [-Wimplicit-int] main.c: At top level: main.c:39:1: warning: return type defaults to 'int' [-Wimplicit-int] 39 | main(){ | ^~~~ main.c: In function 'main': main.c:41:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 41 | scanf("%d",&n); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | typedef struct { main.c:41:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 41 | scanf("%d",&n); | ^~~~~ main.c:41:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:53:17: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 53 | printf("%ld\n",t[0].t+(n-1)*3); | ^~~~~~ main.c:53:17: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:53:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:53:17: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
typedef struct { long t; long h; } N; N t[1<<18]; n;m; mk(i,a,b){ if(a<b-1){ int c=a+b>>1; mk(i*2+1,a,c); mk(i*2+2,c,b); t[i].t=t[i*2+1].t>t[i*2+2].t?t[i*2+1].t:t[i*2+2].t; } } void add(int i,int a,int b,int l,int r,long d){ if(a>=l&&b<=r){ t[i].t+=d; t[i].h+=d; }else{ t[i*2+1].t+=t[i].h; t[i*2+1].h+=t[i].h; t[i*2+2].t+=t[i].h; t[i*2+2].h+=t[i].h; t[i].h=0; int c=a+b>>1; if(c>l){ add(i*2+1,a,c,l,r,d); } if(c<r){ add(i*2+2,c,b,l,r,d); } t[i].t=t[i*2+1].t>t[i*2+2].t?t[i*2+1].t:t[i*2+2].t; } } main(){ int i; scanf("%d",&n); for(i=0;i<n-1;++i){ int x; scanf("%d",&x); t[i|1<<17].t=x-i*3; } mk(0,0,1<<17); scanf("%d",&m); for(i=0;i<m;++i){ int l,r,d; scanf("%d%d%d",&l,&r,&d); add(0,0,1<<17,l,r+1,d); printf("%ld\n",t[0].t+(n-1)*3); } }