QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#72116#5080. Folding Stickricky0129#WA 2ms3912kbC++141003b2023-01-14 05:43:012023-01-14 05:43:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-14 05:43:02]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3912kb
  • [2023-01-14 05:43:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define FOR(i,n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second

const int MOD = (int)1e9+7;

int n;
const int N = 1e5+1;
int A[N];
int dp[N];
int solve(int i){
    if(i>=n) return 0;
    if(dp[i]!=-1) return dp[i];
    //ingore the fold
    int ans = solve(i+1);
    int j = i;
    ll curr = 0;
    while(j<n && curr<A[i]){
        j++;
        curr+=A[j];
    }
    if(j==n-1) j++;
    //cout<<i<<" "<<j<<endl;
    ans = max(ans,solve(j)+A[i]);
    return ans;
}
int main()
{
    cin>>n;
    ll tot = 0;
    FOR(i,n){
        cin>>A[i];
        tot+=A[i];
    }
    memset(dp,-1,sizeof(dp));
    tot-=solve(0);
    cout<<tot<<endl;
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3868kb

input:

4
3 2 2 3

output:

4

result:

ok single line: '4'

Test #2:

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

input:

5
1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

7
1 3 2 3 4 2 2

output:

6

result:

ok single line: '6'

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3912kb

input:

9
5 6 3 4 8 8 2 2 5

output:

12

result:

wrong answer 1st lines differ - expected: '9', found: '12'