QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#700547#5080. Folding Sticktamthegod#WA 0ms3876kbC++231.4kb2024-11-02 13:09:132024-11-02 13:09:13

Judging History

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

  • [2024-11-02 13:09:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3876kb
  • [2024-11-02 13:09:13]
  • 提交

answer

#include<bits/stdc++.h>

#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 1e6 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;

int n;
vector<int> a;
vector<int> p{0};

void ReadInput()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
        p.push_back(p.back() + x);
    }
}

int wrap(int start) {
    int cur = p[start];
    int cur_idx = start;

    while (1) {
        auto it = lower_bound(p.begin(), p.end(), p[cur_idx] + cur);

        if (it == p.end())
            break;

        int jump = it - p.begin();
        cur = max(cur, p[jump] - p[cur_idx]);
        cur_idx = jump;
    }

    return cur;
}

void Solve()
{
    int ans = oo;

    for (int i = 1; i < n; i++) {
        int w = wrap(i);
        ans = min(ans, w);
    }

    cout << ans << endl;
}
#define taskname ""
int32_t main()
{
    if (fopen(taskname ".inp", "r"))
    {
        freopen(taskname ".inp", "r", stdin);
        freopen(taskname ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    //cin >> T;
    for(int itest=1; itest<=T; itest++)
    {
        ReadInput();
        Solve();
    }
}


詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3876kb

input:

4
3 2 2 3

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

5
1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

7
1 3 2 3 4 2 2

output:

6

result:

ok single line: '6'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

9
5 6 3 4 8 8 2 2 5

output:

9

result:

ok single line: '9'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

10
5 6 3 4 8 6 2 1 8 5

output:

9

result:

ok single line: '9'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

10
5 8 1 2 6 8 4 3 6 5

output:

14

result:

ok single line: '14'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

3
4 2 1

output:

4

result:

ok single line: '4'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

14
7 2 2 2 2 3 4 1 3 5 4 3 1 6

output:

8

result:

ok single line: '8'

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

35
46 93 64 27 72 55 77 11 17 17 79 83 74 26 32 101 54 112 92 111 77 60 51 19 105 11 68 7 100 49 88 54 106 80 57

output:

377

result:

wrong answer 1st lines differ - expected: '366', found: '377'