Submission #1225688


Source Code Expand

#include <bits/stdc++.h>

// Shabdan Batyrkulov

using namespace std;

#define MAX 1007
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
#define ll long long
#define ld long double

const long long N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;

ll n, k;
vector <ll> a;
ll ans = 0;

int main () {
        ios::sync_with_stdio(0);
        scanf ("%I64d %I64d", &n, &k);
        a = vector <ll> (n); ll t = 0, s = 0;
        for (ll i = 0; i < n; i++) {
                scanf ("%I64d", &a[i]);
                if (a[i] > 0) t += a[i];
        }
        s = t;
        for (ll i = 0; i < k; i++) {
                if (a[i] > 0) t -= a[i];
                else s += a[i];
        }
        ans = max(ans, max(s, t));
        for (ll i = k, j = 0; i < n; i++, j++) {
                if (a[j] > 0) t += a[j];
                else s -= a[j];
                if (a[i] > 0) t -= a[i];
                else s += a[i];
                ans = max(ans, max(s, t));
        }
        printf ("%I64d\n", ans);
}

Submission Info

Submission Time
Task B - Contiguous Repainting
User Shabdan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1069 Byte
Status WA
Exec Time 56 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:24:37: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
         scanf ("%I64d %I64d", &n, &k);
                                     ^
./Main.cpp:24:37: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat=]
./Main.cpp:27:38: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type* {aka long long int*}’ [-Wformat=]
                 scanf ("%I64d", &a[i]);
                                      ^
./Main.cpp:43:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
         printf ("%I64d\n", ans);
                               ^
./Main.cpp:24:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%I64d %I64d", &n, &k...

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
WA × 4
AC × 3
WA × 23
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt
Case Name Status Exec Time Memory
0_00.txt WA 1 ms 256 KB
0_01.txt WA 1 ms 256 KB
0_02.txt WA 1 ms 256 KB
0_03.txt WA 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt WA 1 ms 256 KB
1_03.txt AC 17 ms 1024 KB
1_04.txt WA 27 ms 1024 KB
1_05.txt WA 27 ms 1024 KB
1_06.txt WA 55 ms 1024 KB
1_07.txt WA 55 ms 1024 KB
1_08.txt WA 55 ms 1024 KB
1_09.txt WA 56 ms 1024 KB
1_10.txt WA 55 ms 1024 KB
1_11.txt WA 56 ms 1024 KB
1_12.txt WA 54 ms 1024 KB
1_13.txt WA 55 ms 1024 KB
1_14.txt WA 55 ms 1024 KB
1_15.txt WA 55 ms 1024 KB
1_16.txt WA 56 ms 1024 KB
1_17.txt WA 55 ms 1024 KB
1_18.txt WA 55 ms 1024 KB
1_19.txt WA 55 ms 1024 KB
1_20.txt WA 55 ms 1024 KB
1_21.txt WA 56 ms 1024 KB