Submission #6567391


Source Code Expand

Copy
#include <stdio.h>

int main(){
  int N;
  int A[100001], B[100000];
  long long int sum=0;
  
  scanf("%d", &N);

  for(int i=0;i<=N;i++)
    scanf("%d", &A[i]);

  for(int i=0;i<N;i++)
    scanf("%d", &B[i]);

  for(int i=0;i<N;i++)
    if(A[i]<B[i]){
      sum += A[i];
      B[i] -= A[i];
      if(A[i+1] > B[i] ){
	sum += B[i];
	A[i+1] -= B[i];
      }else{
	sum += A[i+1];
	A[i+1] =0;
      }
    }else{
      sum += B[i];
      B[i] = 0;
    }

  printf("%lld\n",sum);
  return 0;
}

Submission Info

Submission Time
Task C - City Savers
User FlatHarvest
Language C (GCC 5.4.1)
Score 300
Code Size 524 Byte
Status AC
Exec Time 26 ms
Memory 896 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:8:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
   ^
./Main.c:11:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &A[i]);
     ^
./Main.c:14:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &B[i]);
     ^

Judge Result

Set Name All Sample
Score / Max Score 300 / 300 0 / 0
Status
AC × 17
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 1 ms 128 KB
sample_02 AC 1 ms 128 KB
sample_03 AC 0 ms 128 KB
testcase_01 AC 16 ms 640 KB
testcase_02 AC 14 ms 640 KB
testcase_03 AC 26 ms 896 KB
testcase_04 AC 26 ms 896 KB
testcase_05 AC 6 ms 384 KB
testcase_06 AC 13 ms 640 KB
testcase_07 AC 23 ms 896 KB
testcase_08 AC 25 ms 896 KB
testcase_09 AC 20 ms 768 KB
testcase_10 AC 25 ms 896 KB
testcase_11 AC 21 ms 768 KB
testcase_12 AC 1 ms 128 KB
testcase_13 AC 26 ms 896 KB
testcase_14 AC 0 ms 128 KB