1
0

weight-check.pas 813 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. program hxy;
  2. Const maxn=1000;
  3. infile1='weight.in';
  4. infile2='weight.out';
  5. Var a:array[1..maxn]of longint;
  6. get:array[1..1000000]of integer;
  7. i,j,k,n,m:longint;
  8. begin
  9. assign(input,infile1);
  10. reset(input);
  11. readln(n,m); readln;
  12. fillchar(get,sizeof(get),0);
  13. for i:=1 to 2*n do
  14. begin
  15. read(j);
  16. inc(get[j]);
  17. end;
  18. close(input);
  19. assign(input,infile2);
  20. reset(input);
  21. for i:=1 to n do read(a[i]);
  22. close(input);
  23. j:=0;
  24. for i:=1 to n do
  25. begin
  26. inc(j,a[i]);
  27. dec(get[j]);
  28. if get[j]<0 then begin
  29. writeln('Wa');
  30. exit
  31. end;
  32. end;
  33. j:=0;
  34. for i:=n downto 1 do
  35. begin
  36. inc(j,a[i]);
  37. dec(get[j]);
  38. if get[j]<0 then begin
  39. writeln('Wa');
  40. exit
  41. end;
  42. end;
  43. writeln('Ac');
  44. end.