QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#342661#8281. Pangu and StonesIsaacQWA 0ms3688kbC++14865b2024-03-01 14:33:342024-03-01 14:33:34

Judging History

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

  • [2024-03-01 14:33:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3688kb
  • [2024-03-01 14:33:34]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define pii pair<int,int>
using namespace std;
const ll N = 1e9;
const ll mod = 998244353;
ll sum = 0;
int n, l, r;
void solve()
{
    ll a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a,a+n);
    ll sum[n] = {0};
    sum[0] = a[0];
    for(int i=1; i<n; i++)
    {
        sum[i] = sum[i-1] + a[i]; 
    }
    
    ll dp[n];
    l = l-1;
    r = r-1;
    for(int i=0; i<=r; i++)
    {
        if(i < l) dp[i] = 0;
        else dp[i] = sum[i];
    }

    for(int i=r+1; i<n; i++)
    {
        int k = i - r;
        while(dp[k] == 0 && k <= i - l)
        {
            k++;
        }
        if(k <= i-l) dp[i] = dp[k] + sum[i];
        else dp[i] = 0;
    }


    cout << dp[n-1] << endl;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> l >> r;
    solve();
}

详细

Test #1:

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

input:

3 2 2
1 2 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

3 2 3
1 2 3

output:

6

result:

ok 1 number(s): "6"

Test #3:

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

input:

4 3 3
1 2 3 4

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

100 4 7
570 608 194 26 243 470 418 119 1000 936 440 302 797 155 676 283 869 60 959 793 158 397 808 656 379 316 485 854 753 280 543 435 756 822 106 561 402 347 99 739 8 682 834 549 812 32 338 765 699 575 575 785 171 504 335 113 284 612 276 518 835 677 865 900 687 48 859 179 343 318 626 812 523 11 400...

output:

304423

result:

wrong answer 1st numbers differ - expected: '120446', found: '304423'