QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#702208#5080. Folding Sticktamthegod#TL 93ms13684kbC++231.4kb2024-11-02 15:29:452024-11-02 15:29:46

Judging History

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

  • [2024-11-02 15:29:46]
  • 评测
  • 测评结果:TL
  • 用时:93ms
  • 内存:13684kb
  • [2024-11-02 15:29:45]
  • 提交

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, a[maxN];
int sum[maxN];
int f[maxN];
void ReadInput()
{
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    for(int i=1; i<=n; i++)
        sum[i] = sum[i - 1] + a[i];
}
void Solve()
{
    memset(f, 373, sizeof f);
  //  cout << f[0];return;
    f[0] = 0;
   // cout << sum[1] - sum[0];return;
    for(int i=1; i<=n; i++)
    {
        for(int j=0; j<i; j++)
            if(f[j] <= sum[i] - sum[j]) f[i] = min(f[i], sum[i] - sum[j]);
        //f[i] = sum[i] - sum[high];
        //cout << f[i] + sum[n] - sum[i] << " ";
    }
    //cout << f[1];return;
    int res = oo;
    for(int i=1; i<=n; i++)
        res = min(res, max(f[i], sum[n] - sum[i]));
    cout << res;
}
#define taskname "D"
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: 2ms
memory: 13544kb

input:

4
3 2 2 3

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 3ms
memory: 13604kb

input:

5
1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

7
1 3 2 3 4 2 2

output:

6

result:

ok single line: '6'

Test #4:

score: 0
Accepted
time: 3ms
memory: 13540kb

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: 13484kb

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: 13484kb

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: 13684kb

input:

3
4 2 1

output:

4

result:

ok single line: '4'

Test #8:

score: 0
Accepted
time: 2ms
memory: 13476kb

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: 0
Accepted
time: 0ms
memory: 13476kb

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:

366

result:

ok single line: '366'

Test #10:

score: 0
Accepted
time: 2ms
memory: 13476kb

input:

150
87 121 113 120 23 32 107 92 107 40 61 29 100 120 30 62 61 53 103 40 110 56 16 38 12 55 11 71 109 26 60 72 19 121 74 97 11 87 117 32 58 40 104 91 101 118 19 59 79 21 40 111 100 36 105 58 122 61 33 75 66 11 65 97 84 28 90 18 76 68 70 58 112 100 95 28 61 25 24 110 93 117 80 119 105 52 66 66 101 77 ...

output:

765

result:

ok single line: '765'

Test #11:

score: 0
Accepted
time: 2ms
memory: 13540kb

input:

200
52 59 17 69 83 28 76 102 79 67 66 19 14 114 28 50 68 88 92 23 84 38 71 51 77 76 30 82 67 18 34 41 92 23 72 35 27 94 96 74 12 92 32 60 56 42 123 38 14 99 20 83 16 111 47 101 33 34 81 111 123 108 53 45 73 59 11 26 65 59 111 86 81 73 86 106 101 37 109 56 91 91 26 77 122 99 118 42 43 103 118 19 116 ...

output:

842

result:

ok single line: '842'

Test #12:

score: 0
Accepted
time: 93ms
memory: 13552kb

input:

9999
96 57 105 94 47 39 95 44 103 98 84 99 94 109 65 83 113 102 57 67 13 81 113 31 123 55 27 76 74 94 12 40 88 91 52 78 60 76 118 43 92 102 13 118 76 47 64 99 80 83 108 14 120 16 12 105 82 24 102 99 52 121 81 72 14 74 108 58 117 24 72 14 56 58 122 50 70 114 87 60 61 21 54 58 103 56 75 51 112 27 23 5...

output:

6191

result:

ok single line: '6191'

Test #13:

score: -100
Time Limit Exceeded

input:

19999
364 153 315 275 342 148 43 15 31 494 383 145 452 419 49 244 487 500 394 168 130 300 285 420 304 437 302 515 88 318 13 18 169 156 151 162 259 487 360 63 143 251 245 330 175 429 145 62 158 195 268 33 88 399 134 373 463 510 402 15 244 498 200 82 185 314 360 75 187 327 291 383 67 492 175 298 394 4...

output:

35836

result: