結果
| 問題 | No.3516 Very Large Range Mod |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-24 23:59:57 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,527 bytes |
| 記録 | |
| コンパイル時間 | 2,525 ms |
| コンパイル使用メモリ | 346,436 KB |
| 実行使用メモリ | 14,256 KB |
| 最終ジャッジ日時 | 2026-04-25 00:00:12 |
| 合計ジャッジ時間 | 13,917 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define si(a) (long)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename S,typename F>bool chmin(S&a,F b){return b<a?(a=b,1):0;}
template<typename S,typename F>bool chmax(S&a,F b){return b>a?(a=b,1):0;}
bool _=(ios::sync_with_stdio(0),cin.tie(0),cout<<fixed<<setprecision(16),0);
#include<atcoder/math>
#define lbi(a,x) (lower_bound(all(a),x)-a.begin())
long f(long n, long m, long a, long b){
long ret=0;
ret+=n;
ret-=atcoder::floor_sum(n,m,a,b+(m-1));
ret+=atcoder::floor_sum(n,m,a,b);
return ret;
}
int main(){
long N,K,M;
cin>>N>>K>>M;
vector<long> B(N+1,0);
vector<long> C(N,0);
rep(i,N)cin>>B[i+1],B[i+1]+=B[i];
rep(i,N)cin>>C[i];
C.push_back(0);
vector<long> E(N+1,0);
rep(i,N)E[i+1]=E[i]+(B[i+1]-B[i])*C[i];
vector<long> D;
rep(i,N+1){
D.push_back(B[i]);
if(B[i]+K<B.back())D.push_back(B[i]+K);
}
D.push_back(D.back()+1);
sort(all(D));
D.erase(unique(all(D)),D.end());
auto SUM=[&](long r)->long {
if(r==0)return 0;
if(r==B[N]) return E[N];
int i=lbi(B,r+1)-1;
return E[i]+(r-B[i])*C[i];
};
long ans=0;
rep(i,si(D)-1){
if(D[i]<K)continue;
long w=D[i+1]-D[i];
int l=lbi(B,D[i]-K-1);
int r=lbi(B,D[i]-1);
long s=SUM(D[i])-SUM(D[i]-K);
ans+=f(w,M,C[r]-C[l],s);
}
cout<<ans<<"\n";
}