QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#53862#2929. Concert Rehearsalabdelrahman001Compile Error//C++2.5kb2022-10-06 06:14:372022-10-06 06:14:40

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-06 06:14:40]
  • 评测
  • [2022-10-06 06:14:37]
  • 提交

answer

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 2e5 + 5;
int n, p, k, a[N], pos[N];
ll sum[N];
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> p >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        int rem = p % sum[n];
        if(sum[n] - sum[i - 1] >= rem) {
            pos[i] = i;
            int low = i, high = n, mid;
            while(low <= high) {
                mid = low + high >> 1;
                if(sum[mid] - sum[i - 1] <= rem)
                    pos[i] = mid, low = mid + 1;
                else
                    high = mid - 1;
            }
        } else {
            pos[i] = n;
            rem -= sum[n] - sum[i - 1];
            int low = 1, high = i - 1, mid;
            while(low <= high) {
                mid = low + high >> 1;
                if(sum[mid] <= rem)
                    pos[i] = mid, low = mid + 1;
                else
                    high = mid - 1;
            }
        }
    }
    int lst = 0;
    set<int> st;
    vector<int> v;
    for(int i = 1;i <= k + 1;i++) {
        int nxt = lst + 1;
        if(nxt == n + 1)
            nxt = 1;
        if(st.count(nxt)) {
            lst = nxt;
            break;
        }
        v.push_back(nxt);
        st.insert(nxt);
        lst = pos[nxt];
    }
    ll cnt = (p / sum[n]) * k * n;
    if(p % sum[n] == 0)
        return cout << cnt / n, 0;
    if(n == 1)
        return cout << (p / a[0]) * k;
    int rem = 0;
    for(int i = 0;i < v.size();i++) {
        if(v[i] == lst) {
            ll cycLen = v.size() - i;
            cnt += ((k - i) / cycLen) * n;
            rem = (k - i) % cycLen;
            break;
        }
        if(i + 1 < v.size()) {
            if(v[i + 1] < v[i])
                cnt += n - v[i] + v[i + 1];
            else
                cnt += v[i + 1] - v[i];
        }
    }
    lst--;
    while(rem--) {
        int nxt = lst + 1;
        if(nxt == n + 1)
            nxt = 1;
        if(pos[nxt] < nxt)
            cnt += n - nxt + pos[nxt];
        else
            cnt += pos[nxt] - nxt + 1;
        lst = pos[nxt];
    }
    cout << cnt / n;
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:62:21: error: cannot convert ‘std::basic_ostream<char>’ to ‘int’ in return
   62 |         return cout << (p / a[0]) * k;
      |                ~~~~~^~~~~~~~~~~~~~~~~
      |                     |
      |                     std::basic_ostream<char>