Submission #72359662


Source Code Expand

#if !__INCLUDE_LEVEL__
#include __FILE__

void solve() {
  int N,W;
  cin>>N>>W;
  int M=W*2;
  vl A(2*W,0);
  rep(i,N){
    ll x;
    cin>>x;
    A[(i+1)%(M)]+=x;
  }
  rep(i,M)A.pb(A[i]);
  rep(i,A.size()-1)A[i+1]+=A[i];
  ll ans=LLONG_MAX;
  rep(i,min(N,M)){
    int r=i+W+1;
    int l=i+1;
    chmin(ans,A[r]-A[l]);
  }
  cout<<ans<<el;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T=1;
    cin>>T;
    while(T--)solve();
}

#else
#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint=modint998244353;
//using mint=modint1000000007;
  
// 関数テンプレート
template<typename T> bool chmax(T &m, const T q) {
    if (m < q) {m = q; return true;} else return false; }

template<typename T> bool chmin(T &m,const T q){
    if(m>q){m=q;return true;}else return false;
}
template<typename T>
bool grid_inside(const T h, const T w, const T &m, const T &n) {
    return (m >= 0 && m < h && n >= 0 && n < w);
}
// ループマクロ
#define rep(i,r) for(int i=0;(r)>i;i++)
#define REP(i,l,r) for(int i=(l);i<(r);i++)
#define rrep(i,N) for(int i=(N)-1;i>=0;i--)
#define RREP(i,r,N) for(int i=(N)-1;i>=r;i--)

// コンテナショートカット
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define pb push_back
#define fixed15 std::fixed << std::setprecision(15)
// YES/NO 出力
#define Yes cout<<"Yes"<<el
#define No cout<<"No"<<el
#define YES cout<<"YES"<<el
#define NO cout<<"NO"<<el
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

// 型エイリアス
using ll=long long;
using ull=unsigned long long;
using pqgi=priority_queue<int, vector<int>, greater<int>>;
using pqgl=priority_queue<long long, vector<long long>, greater<long long>>;
using pqgpl=priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>>;
using pqgptpl=priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>>;
using pqi=priority_queue<int>;
using pii=pair<int, int>;
using tpi=tuple<int,int,int>;
using tpl=tuple<ll,ll,ll>;
using pll=pair<long long, long long>;
using vs=vector<string>;
using vi=vector<int>;
using vb=vector<bool>;
using vl=vector<long long>;
using vc=vector<char>;
using vvi=vector<vector<int>>;
using vvl=vector<vector<long long>>;
using vvc=vector<vector<char>>;
using vvb=vector<vector<bool>>;
using vvs=vector<vector<string>>;
using vpii=vector<pii>;
using vpll=vector<pll>;
using vvpii=vector<vector<pii>>;
using vvpll=vector<vector<pll>>;
using vtiii=vector<tuple<int, int, int>>;
using lb=long double;

// 定数
const long long INF=1e18;
const int mod=1e9+7;
//const int mod=998244353;
const int MAX=1e5+10;
const int MIN=-1e9;
const vpii dir={{1,0},{-1,0},{0,1},{0,-1}};
#endif


Submission Info

Submission Time
Task C - Striped Horse
User yasaikeikaku
Language C++23 (GCC 15.2.0)
Score 300
Code Size 3093 Byte
Status AC
Exec Time 13 ms
Memory 9532 KiB

Compile Error

In file included from ./Main.cpp:2:
./Main.cpp: In function 'void solve()':
././Main.cpp:53:33: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 | #define rep(i,r) for(int i=0;(r)>i;i++)
./Main.cpp:15:3: note: in expansion of macro 'rep'
   15 |   rep(i,A.size()-1)A[i+1]+=A[i];
      |   ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 27
Set Name Test Cases
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 7 ms 3576 KiB
random_02.txt AC 7 ms 3532 KiB
random_03.txt AC 8 ms 3560 KiB
random_04.txt AC 8 ms 3576 KiB
random_05.txt AC 9 ms 3608 KiB
random_06.txt AC 10 ms 4948 KiB
random_07.txt AC 9 ms 3708 KiB
random_08.txt AC 10 ms 5036 KiB
random_09.txt AC 9 ms 3704 KiB
random_10.txt AC 9 ms 3940 KiB
random_11.txt AC 9 ms 3736 KiB
random_12.txt AC 10 ms 6328 KiB
random_13.txt AC 9 ms 3644 KiB
random_14.txt AC 10 ms 4956 KiB
random_15.txt AC 9 ms 3608 KiB
random_16.txt AC 10 ms 4940 KiB
random_17.txt AC 8 ms 3704 KiB
random_18.txt AC 8 ms 3416 KiB
random_19.txt AC 8 ms 3704 KiB
random_20.txt AC 8 ms 3576 KiB
random_21.txt AC 2 ms 3668 KiB
random_22.txt AC 5 ms 7996 KiB
random_23.txt AC 13 ms 9532 KiB
random_24.txt AC 10 ms 6532 KiB
random_25.txt AC 9 ms 3936 KiB
random_26.txt AC 10 ms 6476 KiB
sample_01.txt AC 1 ms 3568 KiB