提出 #72367757


ソースコード 拡げる

#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
void solve()
{
   
  int n,w; cin>>n>>w;
  vector<int> v(n+1),ans1(2*w,0),ans(2*w,0);
   
  for(int i=1;i<=n;i++)
  {
      cin>>v[i];
      ans1[(i%(2*w))]+=v[i];
      ans[(i%(2*w))]+=v[i];
  }
   
  if(w>=n){
      cout<<"0"<<endl;return;
  }
  for(int i=0;i<2*w;i++)ans.push_back(ans1[i]);
   
  int mn=LLONG_MAX,l=0,r=0,sum=0;
  while(r<ans.size())
  {
      sum+=ans[r];
      if(r-l+1==w){
          mn=min(sum,mn);
          sum-=ans[l];
          l++;
      }
      r++;
  }
  cout<<mn<<endl;
   
   
   
}
main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t; cin>>t;
    while(t--)
    solve();
    return 0;
}

提出情報

提出日時
問題 C - Striped Horse
ユーザ faritu23
言語 C++23 (GCC 15.2.0)
得点 300
コード長 777 Byte
結果 AC
実行時間 19 ms
メモリ 11184 KiB

コンパイルエラー

./Main.cpp: In function 'void solve()':
./Main.cpp:24:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   while(r<ans.size())
      |         ~^~~~~~~~~~~
./Main.cpp: At global scope:
./Main.cpp:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   39 | main()
      | ^~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 1
AC × 27
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
random_01.txt AC 17 ms 3620 KiB
random_02.txt AC 18 ms 3520 KiB
random_03.txt AC 19 ms 3648 KiB
random_04.txt AC 18 ms 3592 KiB
random_05.txt AC 10 ms 3672 KiB
random_06.txt AC 12 ms 6260 KiB
random_07.txt AC 10 ms 3748 KiB
random_08.txt AC 13 ms 6776 KiB
random_09.txt AC 10 ms 3660 KiB
random_10.txt AC 11 ms 5948 KiB
random_11.txt AC 10 ms 3536 KiB
random_12.txt AC 14 ms 9264 KiB
random_13.txt AC 10 ms 3672 KiB
random_14.txt AC 13 ms 6564 KiB
random_15.txt AC 11 ms 3744 KiB
random_16.txt AC 12 ms 6192 KiB
random_17.txt AC 10 ms 3748 KiB
random_18.txt AC 10 ms 4708 KiB
random_19.txt AC 10 ms 3744 KiB
random_20.txt AC 10 ms 4088 KiB
random_21.txt AC 2 ms 3596 KiB
random_22.txt AC 4 ms 8116 KiB
random_23.txt AC 13 ms 11184 KiB
random_24.txt AC 13 ms 9472 KiB
random_25.txt AC 11 ms 5756 KiB
random_26.txt AC 14 ms 9740 KiB
sample_01.txt AC 1 ms 3536 KiB