QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#220975#149. PeruAhmed57#0 174ms26408kbC++231.9kb2023-10-21 00:47:072024-09-10 16:44:50

Judging History

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

  • [2024-09-10 16:44:50]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:174ms
  • 内存:26408kb
  • [2024-07-04 02:50:10]
  • 评测
  • [2023-10-21 00:47:07]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#include "peru.h"

long long seg[2500000*4];
long long mod = 1000000007;
void update(int p,int l,int r,int idx,int val){
    if(l==r){
        seg[p] = val;
        return ;
    }
    int md = (l+r)/2;
    if(idx<=md)update(p*2,l,md,idx,val);
    else update(p*2+1,md+1,r,idx,val);
    seg[p] = min(seg[p*2],seg[p*2+1]);
}
long long query(int p,int l,int r,int lq,int rq){
    if(l>=lq&&r<=rq)return seg[p];
    if(r<lq||l>rq)return 1e18;
    int md = (l+r)/2;
    return min(query(p*2,l,md,lq,rq),query(p*2+1,md+1,r,lq,rq));
}
int solve(int n, int k,int* ss){
    int arr[n+1];
    for(int i = 1;i<=n*4;i++)seg[i] = 1e18;
    for(int i = 1;i<=n;i++)arr[i] = ss[i-1];
    long long dp[n+1] = {0};
    update(1,0,n,0,0);
    multiset<long long> s;
    deque<pair<long long,long long>> st;
    for(int i = 1;i<=n;i++){
        long long mi = dp[i-1];
        while(!st.empty()&&arr[st.back().second]<=arr[i]){
            s.erase(s.lower_bound(st.back().first+arr[st.back().second]));
            mi = min(mi,st.back().first);
            st.pop_back();
        }
        st.push_back({mi,i});
        s.insert(mi+arr[i]);
        int la = 0;
        while(!st.empty()&&st[0].second<=i-k){
            cout<<st[0].second<<endl;
            la = st[0].second;
            s.erase(s.lower_bound(arr[st[0].second]+st[0].first));
            st.pop_front();
        }
        if(la<i-k){
        int e = st[0].second;
        s.erase(s.lower_bound(arr[e]+st[0].first));
        st.pop_front();
        long long vl = query(1,0,n,i-k,e-1);
        s.insert(arr[e]+vl);
        st.push_front({vl,e});
        }
        dp[i] =(*s.begin());
        update(1,0,n,i,dp[i]);
    }
    long long ans = 0 , po = 1;
    for(int i = n;i>=1;i--){
        ans+=(dp[i]*po)%mod;ans%=mod;
        po*=23;po%=mod;
    }
    return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 5800kb

input:

2000 170
1054018657 1037445664 1011691297 1009972317 1006506677 1002579733 999792775 999477541 975467893 970302369 968173111 957735623 953086083 938540451 932313113 930563895 924682633 917831575 913506401 908739591 905368525 899452913 894354220 890127447 885923007 583391543 880642788 878397752 87822...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
61
62
63
64
65
66
67
68
69
70
71
72
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
19...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 174ms
memory: 26408kb

input:

400000 1000
1999989721 1999987224 1999984551 1999977673 1999977545 1999976801 1999975837 1999972607 1999956301 1999952801 1999942489 1999940593 1999940337 1999936353 1999936273 1999926073 1999925513 1999922980 1999918301 1999912501 1999909301 1999906125 1999902913 1999895622 1999893617 1999885490 19...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051...

result:

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

Subtask #3:

score: 0
Time Limit Exceeded

Test #34:

score: 0
Time Limit Exceeded

input:

2500000 2000
1073315871 1073250349 1072791751 1072104046 1072071097 1071841833 1071809381 1071710686 1071580105 1071482003 1071383725 1071154701 1070499431 1070335288 1070334157 1069943617 1069681476 1069584279 1069581771 1069322519 1069189353 1069125955 1068832186 1068797487 1068662939 1068565681 1...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...

result: