提出 #75626667


ソースコード 拡げる

#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,k;cin>>n>>k;
    vector<vector<ll>> a(n);
    for(int i=0;i<n;i++){
        int l;cin>>l;
        a.reserve(l);
        for(int j=0;j<l;j++){
            int x;cin>>x;
            a[i]    .pb(x);
        }
    }
    vector<ll> c(n);
    for(int i=0;i<n;i++)cin>>c[i]   ;
    ll curr=k;
    ll ans=-1;
    bool flag=false;
    for(int i=0;i<n;i++){
        ll len=(ll)a[i].size()*c[i] ;
        if(curr<=len){
            ans=a[i] [(curr-1)%a[i].size()];
            flag=1;
            break;
        }
        curr-=len;
    }

    cout<<ans;
    
}

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

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

    return 0;
}

提出情報

提出日時
問題 C - Long Sequence
ユーザ lavi3
言語 C++23 (GCC 15.2.0)
得点 300
コード長 1209 Byte
結果 AC
実行時間 27 ms
メモリ 15824 KiB

コンパイルエラー

./Main.cpp: In function 'void solve()':
./Main.cpp:31:10: warning: variable 'flag' set but not used [-Wunused-but-set-variable]
   31 |     bool flag=false;
      |          ^~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 23
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3368 KiB
00_sample_01.txt AC 1 ms 3432 KiB
00_sample_02.txt AC 1 ms 3368 KiB
01_random_00.txt AC 15 ms 7376 KiB
01_random_01.txt AC 21 ms 10364 KiB
01_random_02.txt AC 13 ms 6320 KiB
01_random_03.txt AC 19 ms 9588 KiB
01_random_04.txt AC 20 ms 9636 KiB
01_random_05.txt AC 18 ms 8484 KiB
01_random_06.txt AC 14 ms 6984 KiB
01_random_07.txt AC 27 ms 15632 KiB
01_random_08.txt AC 10 ms 5968 KiB
01_random_09.txt AC 23 ms 12540 KiB
01_random_10.txt AC 9 ms 5320 KiB
01_random_11.txt AC 9 ms 5336 KiB
01_random_12.txt AC 9 ms 5420 KiB
01_random_13.txt AC 27 ms 15824 KiB
01_random_14.txt AC 27 ms 15732 KiB
01_random_15.txt AC 27 ms 15756 KiB
01_random_16.txt AC 24 ms 13000 KiB
01_random_17.txt AC 21 ms 10288 KiB
01_random_18.txt AC 19 ms 9416 KiB
01_random_19.txt AC 10 ms 5712 KiB