| Task: | Maximum sum |
| Sender: | hundlij1 |
| Submission time: | 2025-09-15 17:32:52 +0300 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | details |
| #2 | WRONG ANSWER | 0.00 s | details |
| #3 | WRONG ANSWER | 0.00 s | details |
| #4 | WRONG ANSWER | 0.00 s | details |
| #5 | WRONG ANSWER | 0.00 s | details |
| #6 | WRONG ANSWER | 0.04 s | details |
| #7 | WRONG ANSWER | 0.04 s | details |
| #8 | WRONG ANSWER | 0.10 s | details |
| #9 | WRONG ANSWER | 0.10 s | details |
| #10 | WRONG ANSWER | 0.10 s | details |
| #11 | WRONG ANSWER | 0.00 s | details |
| #12 | WRONG ANSWER | 0.00 s | details |
| #13 | WRONG ANSWER | 0.00 s | details |
| #14 | WRONG ANSWER | 0.00 s | details |
| #15 | WRONG ANSWER | 0.00 s | details |
Compiler report
input/code.cpp: In function 'void t2()':
input/code.cpp:59:9: warning: variable 'minPos' set but not used [-Wunused-but-set-variable]
59 | int minPos = 0;
| ^~~~~~
input/code.cpp:61:9: warning: variable 'maxPos' set but not used [-Wunused-but-set-variable]
61 | int maxPos = n-1;
| ^~~~~~Code
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
void t1(){
int n, m, k;
cin >> n >> m >> k;
const int MOD = n * 100;
vector<int> pos(k + 1, 0);
vector<int> speed(k + 1, 0);
vector<int> val(n);
for(int i = 0; i < m; i++){
int a;
cin >> a;
val[a] = 1;
}
int posC = 0;
for(int i = 0; i < k; i++){
if(val[posC] == 0){
pos[i+1] = (pos[i] + 100) % MOD;
posC +=1;
posC %= n;
}
else if(val[posC] == 1){
pos[i+1] = (pos[i] + 200) % MOD;
posC +=2;
posC %= n;
}
}
//for(int i = 0; i <= k; i++)
//cout << i << pos[i] << endl;
cout << pos[k] << endl;
}
void t2(){
int n;
cin >> n;
vector<int> nums(n +1,0);
for(int i = 0; i < n; i++){
cin >> nums[i];
}
int min = nums[0];
int minPos = 0;
int max = 0;
int maxPos = n-1;
vector<int> dp(n,0);
dp[0] = nums[0];
for(int i = 1; i < n; i++){
dp[i] += dp[i-1] + nums[i];
if(dp[i] < min){
min = dp[i];
minPos = i;
}
if(dp[i] > max){
max = dp[i];
maxPos = i;
}
}
/*if(minPos + 1 > n) min = dp[minPos -1];
else if(minPos - 1 < 0) min = dp[minPos + 1];
else if(dp[minPos + 1] > dp[minPos -1]){
min = dp[minPos + 1];
}
else {
min = dp[minPos - 1];
}*/
int maxDiff = max - min;
cout << max << " " << min << endl;
cout << maxDiff << endl;
}
int main() {
t2();
return 0;
}Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 1 1 1 1 1 1 1 1 1 1 |
| correct output |
|---|
| 10 |
| user output |
|---|
| 10 1 9 |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 10 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 |
| correct output |
|---|
| -1 |
| user output |
|---|
| 0 -10 10 |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 10 24 7 -27 17 -67 65 -23 58 85 -... |
| correct output |
|---|
| 185 |
| user output |
|---|
| 139 -46 185 |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 10 99 -59 31 83 -79 64 -20 -87 40... |
| correct output |
|---|
| 154 |
| user output |
|---|
| 154 32 122 |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 -19 61 60 33 67 19 -8 92 59 -3... |
| correct output |
|---|
| 383 |
| user output |
|---|
| 364 -19 383 |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 200000 |
| user output |
|---|
| 200000 1 199999 |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 200000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
| correct output |
|---|
| -1 |
| user output |
|---|
| 0 -200000 200000 |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 200000 381082742 830199996 -85684827 ... |
| correct output |
|---|
| 231210956017 |
| user output |
|---|
| 2147447290 -2147438415 -81591 |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 200000 -935928962 -795492223 75287481... |
| correct output |
|---|
| 184607318819 |
| user output |
|---|
| 2147478761 -2147482768 -5767 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 200000 524408131 613017181 -62281009 ... |
| correct output |
|---|
| 360019999220 |
| user output |
|---|
| 2147474132 -2147428031 -65133 |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 1 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 0 1 -1 |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 1 -2 |
| correct output |
|---|
| -2 |
| user output |
|---|
| 0 -2 2 |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 5 -1 -1 -1 -1 -2 |
| correct output |
|---|
| -1 |
| user output |
|---|
| 0 -6 6 |
Test 14
Verdict: WRONG ANSWER
| input |
|---|
| 2 -3 -2 |
| correct output |
|---|
| -2 |
| user output |
|---|
| 0 -5 5 |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 1 -1000000000 |
| correct output |
|---|
| -1000000000 |
| user output |
|---|
| 0 -1000000000 1000000000 |
