結果
問題 |
No.3185 Three Abs
|
ユーザー |
![]() |
提出日時 | 2025-06-20 23:42:56 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 1,238 bytes |
コンパイル時間 | 347 ms |
コンパイル使用メモリ | 28,796 KB |
実行使用メモリ | 8,720 KB |
最終ジャッジ日時 | 2025-06-20 23:42:59 |
合計ジャッジ時間 | 3,475 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:46:9: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration] 46 | write(1,wbuf,wp-wbuf); | ^~~~~ main.c:47:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration] 47 | _exit(0); | ^~~~~ main.c:47:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]
ソースコード
#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 rd_signed() ({int _s=*rp=='-'&&++rp,_v=rd();_s?-_v:_v;}) #define WTHI(v) {unsigned _z=v,_n=0;long _d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;} #define WTLO(v) {unsigned _z=v,_n=8;long _d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;} #define wt(v) ({ulong _v=v;if(_v>=100000000){WTHI(_v/100000000);WTLO(_v%100000000);}else{WTHI(_v);}}) #define rep(v,e) for(typeof(e)v=0;v<e;++v) //#define reps(v,s,e) for(typeof(e)v=s;v<e;++v) #define rrep(v,e) for(typeof(e)v=e;v--;) #define repeat(e) for(typeof(e)_=e;_--;) #define min(a,b) (a<=b?a:b) #define max(a,b) (a>=b?a:b) #define chmax(v,a) (v=v>=a?v:a) typedef unsigned long ulong; char wbuf[1<<25]; int a[200000]; int main(){ char*wp=wbuf; rd_init(); int t=rd(); repeat(t){ int n=rd(); long s=0; rep(i,n){ s+=a[i]=rd_signed()*2; } long b=0,c=0; long z=0,t=s>>1; s=0; rep(i,n){ s+=a[i]; chmax(b,s); chmax(c,-s); chmax(z,b-s+t); chmax(z,c+s-t); } wt(z); *wp++='\n'; } write(1,wbuf,wp-wbuf); _exit(0); }