16562022-12-01 12:47:161478Zenehallgatáscpp11Time limit exceeded 23/50273ms5076 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

const int nMax = 100000;
int n;
vector<int> prefixSum(nMax + 1);

int main()
{
    //ifstream cin("be.txt");

    cin >> n;

    int m;
    cin >> m;

    for (int i = 1; i <= n; i++)
    {
        cin >> prefixSum[i];
        prefixSum[i] += prefixSum[i - 1];
    }

    while (m--)
    {
        int a;
        cin >> a;
        a %= prefixSum[n];
        if (a == 0)
            cout << n << " ";
        else
        {
            cout << lower_bound(prefixSum.begin(), prefixSum.begin() + n, a) - prefixSum.begin() << " ";
        }
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base23/50
1Accepted0/03ms2516 KiB
2Accepted0/0194ms2744 KiB
3Accepted2/24ms2912 KiB
4Accepted2/24ms2992 KiB
5Accepted2/24ms3084 KiB
6Accepted3/34ms3312 KiB
7Accepted3/34ms3292 KiB
8Accepted3/34ms3444 KiB
9Accepted2/2195ms3528 KiB
10Time limit exceeded0/2221ms2692 KiB
11Accepted2/2194ms3828 KiB
12Accepted2/2194ms4056 KiB
13Time limit exceeded0/2264ms3152 KiB
14Time limit exceeded0/2273ms3304 KiB
15Time limit exceeded0/2250ms4716 KiB
16Time limit exceeded0/2207ms4664 KiB
17Time limit exceeded0/2234ms4512 KiB
18Time limit exceeded0/2231ms4748 KiB
19Time limit exceeded0/2209ms3640 KiB
20Accepted2/2185ms4908 KiB
21Time limit exceeded0/2240ms4940 KiB
22Time limit exceeded0/3216ms4948 KiB
23Time limit exceeded0/3229ms4944 KiB
24Time limit exceeded0/3206ms5076 KiB