Submission #1089854

# Submission time Handle Problem Language Result Execution time Memory
1089854 2024-09-17T10:05:31 Z KALARRY Tricks of the Trade (CEOI23_trade) C++14
25 / 100
8000 ms 12884 KB
//chockolateman

#include<bits/stdc++.h>

using namespace std;

long long N,K,a[250005],b[250005],dp[250005][2];

int main()
{
    scanf("%lld%lld",&N,&K);
    for(long long i = 1 ; i <= N ; i++)
        scanf("%lld",&a[i]);
    for(long long i = 1 ; i <= N ; i++)
        scanf("%lld",&b[i]);
    for(long long j = 1 ; j <= K ; j++)
        dp[0][j%2] = -1e15;
    for(long long j = 1 ; j <= K ; j++)
    {
        for(long long i = 1 ; i <= N ; i++)
            dp[i][j%2] = max(dp[i-1][j%2] - a[i],dp[i-1][(j-1)%2] + b[i] - a[i]);
    }
    long long ans = -1e15;
    for(long long i = 1 ; i <= N ; i++)
        ans = max(ans,dp[i][K%2]);
    printf("%lld\n",ans);
    return 0;
}

Compilation message

trade.cpp: In function 'int main()':
trade.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld%lld",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
trade.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
trade.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld",&b[i]);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Partially correct 0 ms 348 KB Partially correct
4 Partially correct 0 ms 348 KB Partially correct
5 Partially correct 0 ms 348 KB Partially correct
6 Partially correct 0 ms 448 KB Partially correct
7 Partially correct 1 ms 344 KB Partially correct
8 Partially correct 1 ms 348 KB Partially correct
9 Partially correct 1 ms 348 KB Partially correct
10 Partially correct 0 ms 348 KB Partially correct
11 Partially correct 0 ms 348 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Partially correct 0 ms 348 KB Partially correct
4 Partially correct 0 ms 348 KB Partially correct
5 Partially correct 0 ms 348 KB Partially correct
6 Partially correct 0 ms 448 KB Partially correct
7 Partially correct 1 ms 344 KB Partially correct
8 Partially correct 1 ms 348 KB Partially correct
9 Partially correct 1 ms 348 KB Partially correct
10 Partially correct 0 ms 348 KB Partially correct
11 Partially correct 0 ms 348 KB Partially correct
12 Partially correct 0 ms 348 KB Partially correct
13 Partially correct 0 ms 444 KB Partially correct
14 Partially correct 1 ms 348 KB Partially correct
15 Partially correct 1 ms 348 KB Partially correct
16 Partially correct 0 ms 348 KB Partially correct
17 Partially correct 0 ms 348 KB Partially correct
18 Partially correct 1 ms 348 KB Partially correct
19 Partially correct 0 ms 348 KB Partially correct
20 Partially correct 1 ms 604 KB Partially correct
21 Partially correct 1 ms 348 KB Partially correct
22 Partially correct 1 ms 348 KB Partially correct
23 Partially correct 39 ms 604 KB Partially correct
24 Partially correct 1 ms 544 KB Partially correct
25 Partially correct 8 ms 604 KB Partially correct
26 Partially correct 2 ms 604 KB Partially correct
27 Partially correct 18 ms 660 KB Partially correct
28 Partially correct 1 ms 604 KB Partially correct
29 Partially correct 19 ms 712 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 25 ms 8076 KB Partially correct
3 Partially correct 35 ms 8216 KB Partially correct
4 Partially correct 34 ms 8020 KB Partially correct
5 Partially correct 35 ms 8020 KB Partially correct
6 Partially correct 33 ms 8020 KB Partially correct
7 Partially correct 33 ms 8016 KB Partially correct
8 Partially correct 35 ms 8240 KB Partially correct
9 Partially correct 27 ms 8028 KB Partially correct
10 Partially correct 31 ms 8188 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 25 ms 8076 KB Partially correct
3 Partially correct 35 ms 8216 KB Partially correct
4 Partially correct 34 ms 8020 KB Partially correct
5 Partially correct 35 ms 8020 KB Partially correct
6 Partially correct 33 ms 8020 KB Partially correct
7 Partially correct 33 ms 8016 KB Partially correct
8 Partially correct 35 ms 8240 KB Partially correct
9 Partially correct 27 ms 8028 KB Partially correct
10 Partially correct 31 ms 8188 KB Partially correct
11 Partially correct 1 ms 348 KB Partially correct
12 Partially correct 25 ms 8060 KB Partially correct
13 Partially correct 36 ms 8112 KB Partially correct
14 Partially correct 34 ms 8156 KB Partially correct
15 Partially correct 34 ms 8020 KB Partially correct
16 Partially correct 32 ms 8028 KB Partially correct
17 Partially correct 40 ms 8024 KB Partially correct
18 Partially correct 33 ms 8272 KB Partially correct
19 Partially correct 26 ms 8028 KB Partially correct
20 Partially correct 30 ms 8020 KB Partially correct
21 Partially correct 0 ms 344 KB Partially correct
22 Partially correct 0 ms 348 KB Partially correct
23 Partially correct 0 ms 348 KB Partially correct
24 Partially correct 0 ms 344 KB Partially correct
25 Partially correct 0 ms 348 KB Partially correct
26 Partially correct 0 ms 348 KB Partially correct
27 Partially correct 0 ms 348 KB Partially correct
28 Partially correct 0 ms 348 KB Partially correct
29 Partially correct 0 ms 348 KB Partially correct
30 Partially correct 0 ms 444 KB Partially correct
31 Partially correct 85 ms 11140 KB Partially correct
32 Partially correct 35 ms 11044 KB Partially correct
33 Partially correct 95 ms 10848 KB Partially correct
34 Partially correct 96 ms 10600 KB Partially correct
35 Partially correct 81 ms 10328 KB Partially correct
36 Partially correct 78 ms 9552 KB Partially correct
37 Partially correct 84 ms 9048 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB Partially correct
2 Partially correct 0 ms 348 KB Partially correct
3 Partially correct 0 ms 348 KB Partially correct
4 Partially correct 0 ms 348 KB Partially correct
5 Partially correct 0 ms 348 KB Partially correct
6 Partially correct 0 ms 348 KB Partially correct
7 Partially correct 0 ms 348 KB Partially correct
8 Partially correct 0 ms 448 KB Partially correct
9 Partially correct 1 ms 344 KB Partially correct
10 Partially correct 1 ms 348 KB Partially correct
11 Partially correct 1 ms 348 KB Partially correct
12 Partially correct 0 ms 348 KB Partially correct
13 Partially correct 0 ms 348 KB Partially correct
14 Partially correct 0 ms 348 KB Partially correct
15 Partially correct 0 ms 444 KB Partially correct
16 Partially correct 1 ms 348 KB Partially correct
17 Partially correct 1 ms 348 KB Partially correct
18 Partially correct 0 ms 348 KB Partially correct
19 Partially correct 0 ms 348 KB Partially correct
20 Partially correct 1 ms 348 KB Partially correct
21 Partially correct 0 ms 348 KB Partially correct
22 Partially correct 1 ms 604 KB Partially correct
23 Partially correct 1 ms 348 KB Partially correct
24 Partially correct 1 ms 348 KB Partially correct
25 Partially correct 39 ms 604 KB Partially correct
26 Partially correct 1 ms 544 KB Partially correct
27 Partially correct 8 ms 604 KB Partially correct
28 Partially correct 2 ms 604 KB Partially correct
29 Partially correct 18 ms 660 KB Partially correct
30 Partially correct 1 ms 604 KB Partially correct
31 Partially correct 19 ms 712 KB Partially correct
32 Partially correct 0 ms 348 KB Partially correct
33 Partially correct 25 ms 8076 KB Partially correct
34 Partially correct 35 ms 8216 KB Partially correct
35 Partially correct 34 ms 8020 KB Partially correct
36 Partially correct 35 ms 8020 KB Partially correct
37 Partially correct 33 ms 8020 KB Partially correct
38 Partially correct 33 ms 8016 KB Partially correct
39 Partially correct 35 ms 8240 KB Partially correct
40 Partially correct 27 ms 8028 KB Partially correct
41 Partially correct 31 ms 8188 KB Partially correct
42 Partially correct 1 ms 348 KB Partially correct
43 Partially correct 25 ms 8060 KB Partially correct
44 Partially correct 36 ms 8112 KB Partially correct
45 Partially correct 34 ms 8156 KB Partially correct
46 Partially correct 34 ms 8020 KB Partially correct
47 Partially correct 32 ms 8028 KB Partially correct
48 Partially correct 40 ms 8024 KB Partially correct
49 Partially correct 33 ms 8272 KB Partially correct
50 Partially correct 26 ms 8028 KB Partially correct
51 Partially correct 30 ms 8020 KB Partially correct
52 Partially correct 0 ms 344 KB Partially correct
53 Partially correct 0 ms 348 KB Partially correct
54 Partially correct 0 ms 348 KB Partially correct
55 Partially correct 0 ms 344 KB Partially correct
56 Partially correct 0 ms 348 KB Partially correct
57 Partially correct 0 ms 348 KB Partially correct
58 Partially correct 0 ms 348 KB Partially correct
59 Partially correct 0 ms 348 KB Partially correct
60 Partially correct 0 ms 348 KB Partially correct
61 Partially correct 0 ms 444 KB Partially correct
62 Partially correct 85 ms 11140 KB Partially correct
63 Partially correct 35 ms 11044 KB Partially correct
64 Partially correct 95 ms 10848 KB Partially correct
65 Partially correct 96 ms 10600 KB Partially correct
66 Partially correct 81 ms 10328 KB Partially correct
67 Partially correct 78 ms 9552 KB Partially correct
68 Partially correct 84 ms 9048 KB Partially correct
69 Partially correct 0 ms 348 KB Partially correct
70 Partially correct 27 ms 9216 KB Partially correct
71 Partially correct 36 ms 11088 KB Partially correct
72 Partially correct 37 ms 11284 KB Partially correct
73 Partially correct 34 ms 11164 KB Partially correct
74 Partially correct 34 ms 10768 KB Partially correct
75 Partially correct 32 ms 10320 KB Partially correct
76 Partially correct 35 ms 11092 KB Partially correct
77 Partially correct 27 ms 9560 KB Partially correct
78 Partially correct 38 ms 10324 KB Partially correct
79 Partially correct 0 ms 348 KB Partially correct
80 Partially correct 0 ms 348 KB Partially correct
81 Partially correct 0 ms 348 KB Partially correct
82 Partially correct 0 ms 440 KB Partially correct
83 Partially correct 0 ms 348 KB Partially correct
84 Partially correct 1 ms 344 KB Partially correct
85 Partially correct 0 ms 348 KB Partially correct
86 Partially correct 0 ms 348 KB Partially correct
87 Partially correct 0 ms 348 KB Partially correct
88 Partially correct 0 ms 348 KB Partially correct
89 Partially correct 86 ms 11348 KB Partially correct
90 Partially correct 35 ms 11004 KB Partially correct
91 Partially correct 80 ms 10736 KB Partially correct
92 Partially correct 81 ms 10464 KB Partially correct
93 Partially correct 87 ms 10324 KB Partially correct
94 Partially correct 76 ms 9556 KB Partially correct
95 Partially correct 75 ms 9052 KB Partially correct
96 Partially correct 39 ms 600 KB Partially correct
97 Partially correct 1 ms 600 KB Partially correct
98 Partially correct 7 ms 572 KB Partially correct
99 Partially correct 2 ms 604 KB Partially correct
100 Partially correct 22 ms 664 KB Partially correct
101 Partially correct 1 ms 604 KB Partially correct
102 Partially correct 20 ms 704 KB Partially correct
103 Execution timed out 8066 ms 12884 KB Time limit exceeded
104 Halted 0 ms 0 KB -