1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  | 
int n,h,H;
int x[MAXN],c[MAXN],wt[MAXN];
inline void work(signed CASE=1,bool FINAL_CASE=false) {
    n=read(); h=read(); H=read();
    for(int i=0;i<2*H;i++) {
        wt[i]=(i>h && 2*H-h-i>0)?wt[i]=2*H-h-i:0;
    }
    for(int i=1;i<=n;i++) {
        x[i]=read();
    }
    for(int i=1;i<=n;i++) {
        c[i]=read();
    }
    int minn=INF,ans=-1;
    for(int i=1;i<=n;i++){
        if(minn>(x[i]+c[i]+wt[(x[i]%(H<<1))])) {
            minn=(x[i]+c[i]+wt[(x[i]%(H<<1))]),ans=i;
        }
    }
    printf("%d\n",ans);
    return;
}
signed main() {
    // ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); //freopen(".in", "r", stdin);//freopen(".out", "w", stdout);
    signed T=(signed)read();//scanf("%d",&T);//cin>>T;
    for(signed CASE=1; CASE<=T; CASE++) { //
        //printf("Case #%d: ",CASE); //printf("Case %d: ",CASE); //printf("Case #%d: \n",CASE); //printf("Case %d: \n",CASE);
        work(CASE,CASE==T);
        if(CASE!=T) {}
    }
    return 0;
}
  |