提出 #75107381


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define pb push_back

template<class T> inline bool chmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool chmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int MOD = 1e9 + 7;

void solve() {
    ll n,m;cin>>n>>m;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i]   ;
    int k=n/2;
    vector<ll> d(k+2,0);
    for(int i=1;i<=k;i++){
        d[i]=(a[i-1]-a[n-i]+m)%m;

    }
    vector<ll> b(k+1);
    ll sumb=0;
    for(int i=0;i<=k;i++){
        b[i]=(d[i+1]-d[i]+m)%m;
        sumb+=b[i];
    }
    ll c=sumb/m;
    sort(all(b));
    ll ans=0;
    for(int i=0;i<(k+1-c);i++){
        ans+=b[i];

    }
    cout<<ans<<'\n';

    
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt = 1;
    cin>>tt;
    while (tt--) {
        solve();
    }

    return 0;
}

提出情報

提出日時
問題 F - Make it Palindrome 2
ユーザ lavi3
言語 C++23 (GCC 15.2.0)
得点 525
コード長 1093 Byte
結果 AC
実行時間 38 ms
メモリ 6524 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 525 / 525
結果
AC × 1
AC × 24
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3520 KiB
01_handmade_00.txt AC 11 ms 6492 KiB
01_handmade_01.txt AC 12 ms 3560 KiB
01_handmade_02.txt AC 12 ms 6492 KiB
01_handmade_03.txt AC 12 ms 6448 KiB
01_handmade_04.txt AC 12 ms 6464 KiB
02_random_00.txt AC 14 ms 5848 KiB
02_random_01.txt AC 17 ms 6476 KiB
02_random_02.txt AC 2 ms 3720 KiB
02_random_03.txt AC 17 ms 6472 KiB
02_random_04.txt AC 3 ms 3720 KiB
02_random_05.txt AC 18 ms 6352 KiB
02_random_06.txt AC 17 ms 6344 KiB
02_random_07.txt AC 17 ms 6524 KiB
02_random_08.txt AC 9 ms 4712 KiB
02_random_09.txt AC 18 ms 6476 KiB
02_random_10.txt AC 38 ms 3564 KiB
02_random_11.txt AC 21 ms 3564 KiB
02_random_12.txt AC 14 ms 3564 KiB
02_random_13.txt AC 14 ms 3532 KiB
02_random_14.txt AC 13 ms 3708 KiB
02_random_15.txt AC 13 ms 3680 KiB
02_random_16.txt AC 14 ms 3696 KiB
02_random_17.txt AC 14 ms 3764 KiB