提出 #27724453


ソースコード 拡げる

// Problem: D - AtArcher
// Contest: AtCoder - AtCoder Regular Contest 131
// URL: https://atcoder.jp/contests/arc131/tasks/arc131_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

// 从未在意的名字永远不会被提起 - 雪葉/鹤见江野

/*
+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
+++++++++++
++++++++++++
+++++++++++++
++++++++++++++
+++++++++++++++
++++++++++++++++
+++++++++++++++++
++++++++++++++++++
+ +++++++++++++++++
+  ++++++++++++++ ++
+   +++++++++++++  ++
+    ++++++++++++   ++
+     +++++++++++    ++
+      ++++++++++     ++
+       +++++++++      ++
+        ++++++++       ++
+         +++++++++++++++++
+          +++++++++++++++++
+           ++++++++++++++
+            +++++++++++
+             ++++++++
+              +++++
+               ++
+               +
+               +
+              ++
+             +++
+            ++++
+           +++++
+           +++++
+           +++++
+           +++++
+     +     +++++
+    +++    +++++
+   ++ ++   +++++
+  ++   ++  +++++
+ ++  +  ++ +++++
+++  +++  +++++++
++  ++ ++  ++++++
 
 
 ++++++++      +++++++++++     +++      +++        ++++++++        ++++++++
+++++++++     +++++++++++++    +++      +++       +++    +++      +++    +++
+++          +++   +++   +++   +++      +++      +++   ++++++    +++      +++
+++          +++   +++   +++   +++      +++      +++ +++  +++           +++
+++          +++   +++   +++   +++ ++   +++ ++   ++++++   +++         +++
+++++++++    +++   +++   +++   +++ ++   +++ ++    +++    +++        +++    ++
 ++++++++    +++   +++   +++   +++++    +++++      ++++++++       +++++++++++
*/
// #define DEBUG
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <assert.h>
#include <set>
#define od(x) printf("%d",x)
#define odb(x) printf("%d ",x)
#define odl(x) printf("%d\n",x)
#define odp(x,y) printf("%d %d\n",x,y)
#define ol(x) puts("")
#define old(x) printf("%lld",x)
#define oldb(x) printf("%lld ",x)
#define oldl(x) printf("%lld\n",x)
#define oldp(x,y) printf("%lld %lld\n",x,y)
#define rg(x) for(int i=1;i<=(x);i++){
#define rg_(i,x) for(int i=1;i<=(x);i++){
#define fe(u) for(int i=h[u];i;i=e[i].nxt){int v=e[i].v;
#define gr }
#define rrg(x) for(int i=0;i<(x);i++)
#define rdln(a) a[i]=read();
#define rdln0(a,x) rrg(x) rdln(a) gr
#define rdln1(a,x) rg(x) rdln(a) gr
template<typename T>
void print(T x){}
template<>
void print<int>(int x){od(x);}
template<>
void print<const int>(const int x){od(x);}
template<>
void print<long long>(long long x){old(x);}
template<>
void print<const long long>(const long long x){old(x);}
template<>
void print<char>(char x){putchar(x);}
template<>
void print<const char>(const char x){putchar(x);}
template<>
void print<double>(double x){printf("%.12lf",x);}
template<typename T,typename... qwq>
void print(T x,qwq ...args)
{
	print(x);
	print(args...);
}
#ifdef DEBUG
template<typename T>
void debug(T x){}
template<>
void debug<int>(int x){od(x);}
template<>
void debug<const int>(const int x){od(x);}
template<>
void debug<long long>(long long x){old(x);}
template<>
void debug<const long long>(const long long x){old(x);}
template<>
void debug<char>(char x){putchar(x);}
template<>
void debug<const char>(const char x){putchar(x);}
template<>
void debug<double>(double x){printf("%.12lf",x);}
template<typename T,typename... qwq>
void debug(T x,qwq ...args)
{
	debug(x);
	debug(args...);
}
#define dflush fflush
#else
#define dflush(...) 0
template<typename T,typename... qwq>
void debug(T x,qwq ...args)
{
	
}
#endif
#define int __int128
#define newe(n) struct Edge{int v,w,nxt;}e[2*n+5];\
typedef int arr[n+5];\
arr h;\
int cnt=1;\
inline void addedge(int u,int v,int w){e[cnt]=(Edge){v,w,h[u]};h[u]=cnt++;}
#define mgs int fa[1<<22],sz[1<<22];\
inline int f(int x){return x==fa[x]?x:fa[x]=f(fa[x]);}\
inline int uf(int x,int y)\
{\
    int fx=f(x),fy=f(y);\
    if(fx==fy)return 0;\
    if(sz[fx]>sz[fy])fx^=fy^=fx^=fy;\
    fa[fx]=fy,sz[fy]+=sz[fx];\
    return 1;\
}
inline int read()
{
    int num=0,f=1;char c=getchar();
    while(c<48||c>57){if(c=='-')f=-1;if(c==-1)return 0;c=getchar();}
    while(c>47&&c<58)num=num*10+(c^48),c=getchar();
    return num*f;
}
inline int re1d()
{
    char c=getchar();
    while(c<48||c>49)c=getchar();
    return c&1;
}
inline int min(int a,int b){return a>b?b:a;}
inline int max(int a,int b){return a<b?b:a;}
int a[2000005],b[2000005],c[2000005];
void add(int l,int r,int v)
{
	// v=1;
	c[l]+=v;
	c[r+1]-=v;
}
int d;
int div(int n)
{
	return (n+1000000000000ll*d)/d-1000000000000ll;
}
int mod(int n)
{
	return n-d*div(n);
}
void wt(int x)
{
	if(x>9)wt(x/10);
	putchar(x%10+48);
}
signed main()
{
	// oldl(1000000000000);
	int n=read(),m=read();d=read();
	// rg(100)odb(div(i-50));gr
	m++;
	rg(m)a[m-i+1]=-(a[i+m-1]=read());gr
	assert(a[m]==0);
	// if(n==1)return oldl(read()),0;
	rg(m)b[m-i+1]=b[i+m]=read();gr
	a[0]=-1e18,a[m*2]=1e18;
	int l=n-1>>1,r=n-l-1;
	// odp(l,r);
	// odp(l,r);
	l=-l*d;
	r=r*d+d-1;
	// for(int i=m;i<=m*2-1;i++)a[i]
	// l-=a[m+1]>>1;r-=a[m+1]>>1;
	// odp(l,r);
	m=m*2;
	// rg(m)oldp(a[i],b[i]);gr
	rg(m)
	int L=a[i-1],R=a[i]-1;
	if(R>0)R++,L=L==0?0:L+1;
	L=max(L,l);R=min(R,r);
	if(L>R)continue;
	int w=b[i];
	// odb(w);odp(L,R);
	if(div(L)==div(R))add(mod(L),mod(R),w);
	else add(mod(L),d-1,w),add(0,mod(R),w),add(0,d-1,w*(div(R)-div(L)-1));
	// if(L>0)L--,R
	// oldp(L,R);
	// L=max()
	gr
	int ans=c[0];
	rg(d-1)c[i]+=c[i-1];//oldl(c[i]);
	ans=max(ans,c[i]);
	gr
	memset(c,0,sizeof(c));
	l-=d-1,r-=d-1;
	rg(m)
	int L=a[i-1],R=a[i]-1;
	if(R>0)R++,L=L==0?0:L+1;
	L=max(L,l);R=min(R,r);
	if(L>R)continue;
	int w=b[i];
	// odb(w);odp(L,R);
	if(div(L)==div(R))add(mod(L),mod(R),w);
	else add(mod(L),d-1,w),add(0,mod(R),w),add(0,d-1,w*(div(R)-div(L)-1));
	// if(L>0)L--,R
	// oldp(L,R);
	// L=max()
	gr
	ans=max(ans,c[0]);
	rg(d-1)c[i]+=c[i-1];//oldl(c[i]);
	ans=max(ans,c[i]);
	gr
	memset(c,0,sizeof(c));
	l=n>>1,r=n-l-1;
	// odp(l,r);
	// odp(l,r);
	l=-l*d;
	r=r*d+d-1;

	rg(m)
	int L=a[i-1],R=a[i]-1;
	if(R>0)R++,L=L==0?0:L+1;
	L=max(L,l);R=min(R,r);
	if(L>R)continue;
	int w=b[i];
	// odb(w);odp(L,R);
	if(div(L)==div(R))add(mod(L),mod(R),w);
	else add(mod(L),d-1,w),add(0,mod(R),w),add(0,d-1,w*(div(R)-div(L)-1));
	// if(L>0)L--,R
	// oldp(L,R);
	// L=max()
	gr
	ans=max(ans,c[0]);
	rg(d-1)c[i]+=c[i-1];//oldl(c[i]);
	ans=max(ans,c[i]);
	gr
memset(c,0,sizeof(c));
	l-=d-1,r-=d-1;
	rg(m)
	int L=a[i-1],R=a[i]-1;
	if(R>0)R++,L=L==0?0:L+1;
	L=max(L,l);R=min(R,r);
	if(L>R)continue;
	int w=b[i];
	// odb(w);odp(L,R);
	if(div(L)==div(R))add(mod(L),mod(R),w);
	else add(mod(L),d-1,w),add(0,mod(R),w),add(0,d-1,w*(div(R)-div(L)-1));
	// if(L>0)L--,R
	// oldp(L,R);
	// L=max()
	gr
	ans=max(ans,c[0]);
	rg(d-1)c[i]+=c[i-1];//oldl(c[i]);
	ans=max(ans,c[i]);
	gr
	wt(ans);
	// int l=d>>1,r=;
	return 0;
}

提出情報

提出日時
問題 D - AtArcher
ユーザ cmll02
言語 C++ (GCC 9.2.1)
得点 0
コード長 7146 Byte
結果 WA
実行時間 113 ms
メモリ 39144 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:212:9: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]
  212 |  int l=n-1>>1,r=n-l-1;
      |        ~^~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 600
結果
AC × 5
AC × 45
WA × 5
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt
All corner_01.txt, corner_02.txt, corner_03.txt, corner_04.txt, corner_05.txt, corner_06.txt, corner_07.txt, corner_08.txt, corner_09.txt, corner_10.txt, corner_11.txt, corner_12.txt, corner_13.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in30.txt, in31.txt, in32.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt
ケース名 結果 実行時間 メモリ
corner_01.txt AC 44 ms 32740 KiB
corner_02.txt AC 40 ms 32740 KiB
corner_03.txt WA 35 ms 32848 KiB
corner_04.txt AC 40 ms 32784 KiB
corner_05.txt WA 40 ms 32832 KiB
corner_06.txt WA 40 ms 32784 KiB
corner_07.txt AC 42 ms 32832 KiB
corner_08.txt AC 41 ms 32820 KiB
corner_09.txt AC 41 ms 32740 KiB
corner_10.txt AC 37 ms 32756 KiB
corner_11.txt AC 41 ms 32848 KiB
corner_12.txt AC 38 ms 32780 KiB
corner_13.txt AC 38 ms 32832 KiB
in01.txt AC 65 ms 34552 KiB
in02.txt AC 75 ms 38456 KiB
in03.txt AC 79 ms 35660 KiB
in04.txt AC 105 ms 39144 KiB
in05.txt AC 69 ms 38504 KiB
in06.txt AC 80 ms 38804 KiB
in07.txt AC 49 ms 32760 KiB
in08.txt AC 40 ms 32780 KiB
in09.txt AC 53 ms 33596 KiB
in10.txt AC 82 ms 38884 KiB
in11.txt AC 113 ms 39008 KiB
in12.txt AC 104 ms 39008 KiB
in13.txt AC 56 ms 35940 KiB
in14.txt AC 71 ms 38820 KiB
in15.txt AC 70 ms 37776 KiB
in16.txt AC 86 ms 38212 KiB
in17.txt AC 94 ms 37740 KiB
in18.txt AC 77 ms 39092 KiB
in19.txt WA 60 ms 38352 KiB
in20.txt WA 58 ms 35984 KiB
in21.txt AC 75 ms 38972 KiB
in22.txt AC 71 ms 37720 KiB
in23.txt AC 104 ms 38564 KiB
in24.txt AC 101 ms 37320 KiB
in25.txt AC 96 ms 38996 KiB
in26.txt AC 82 ms 39036 KiB
in27.txt AC 66 ms 36248 KiB
in28.txt AC 65 ms 39024 KiB
in29.txt AC 76 ms 39144 KiB
in30.txt AC 76 ms 39092 KiB
in31.txt AC 70 ms 38984 KiB
in32.txt AC 67 ms 39100 KiB
sample_01.txt AC 40 ms 32756 KiB
sample_02.txt AC 36 ms 32760 KiB
sample_03.txt AC 38 ms 32752 KiB
sample_04.txt AC 34 ms 32832 KiB
sample_05.txt AC 40 ms 32896 KiB