Submission #1063397
Source Code Expand
#include <stdio.h> #include <string.h> #include <stdbool.h> #define N_MAX 100000 #define M_MAX 1000 #define INF 10000000 #define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b)))) typedef unsigned long long ull; typedef signed long long dll; dll a[N_MAX]; int n, m; int i, j, k; void deb(){ return; } ull abs(dll n){ return (ull)((n > 0) ? n : -n); } void solve(){ dll result = 0; dll total = 0; dll rangetot = 0; for (i = 0; i < n; i++) { if (a[i] >= 0) total += a[i]; } for (i = 0; i < k; i++) { if (a[i] >= 0) total -= a[i]; rangetot += a[i]; } // puts("deb line B"); while (i <= n) { ull candid; candid = total; if (rangetot > 0) candid += rangetot; if (result < candid) result = candid; if (a[i-k] >= 0) total += a[i-k]; rangetot -= a[i-k]; if (a[i] >= 0) total -= a[i]; rangetot += a[i]; i++; } printf("%lld\n", result); return; } int main (void) { scanf("%d%d", &n, &k); for (i = 0; i < n; i++) scanf("%lld", &a[i]); // puts("deb line A"); solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Contiguous Repainting |
User | sheyasutaka |
Language | C (GCC 5.4.1) |
Score | 400 |
Code Size | 1095 Byte |
Status | AC |
Exec Time | 15 ms |
Memory | 896 KB |
Compile Error
./Main.c:22:5: warning: conflicting types for built-in function ‘abs’ ull abs(dll n){ ^ ./Main.c: In function ‘main’: ./Main.c:58:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &k); ^ ./Main.c:59:26: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] for (i = 0; i < n; i++) scanf("%lld", &a[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
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 | AC | 1 ms | 128 KB |
0_01.txt | AC | 1 ms | 128 KB |
0_02.txt | AC | 1 ms | 128 KB |
0_03.txt | AC | 1 ms | 128 KB |
1_00.txt | AC | 1 ms | 128 KB |
1_01.txt | AC | 1 ms | 128 KB |
1_02.txt | AC | 1 ms | 128 KB |
1_03.txt | AC | 10 ms | 896 KB |
1_04.txt | AC | 15 ms | 896 KB |
1_05.txt | AC | 15 ms | 896 KB |
1_06.txt | AC | 14 ms | 896 KB |
1_07.txt | AC | 15 ms | 896 KB |
1_08.txt | AC | 14 ms | 896 KB |
1_09.txt | AC | 14 ms | 896 KB |
1_10.txt | AC | 14 ms | 896 KB |
1_11.txt | AC | 14 ms | 896 KB |
1_12.txt | AC | 14 ms | 896 KB |
1_13.txt | AC | 14 ms | 896 KB |
1_14.txt | AC | 14 ms | 896 KB |
1_15.txt | AC | 14 ms | 896 KB |
1_16.txt | AC | 15 ms | 896 KB |
1_17.txt | AC | 14 ms | 896 KB |
1_18.txt | AC | 14 ms | 896 KB |
1_19.txt | AC | 14 ms | 896 KB |
1_20.txt | AC | 14 ms | 896 KB |
1_21.txt | AC | 14 ms | 896 KB |