Skip to content

Instantly share code, notes, and snippets.

@catupper
Created October 1, 2011 12:55
Show Gist options
  • Save catupper/1256030 to your computer and use it in GitHub Desktop.
Save catupper/1256030 to your computer and use it in GitHub Desktop.
GCJJ2011
A[100],B[100],M,C,W,j;int main(i){for(gets(&M);~scanf("%d%d%d",&M,&C,&W);printf("Case #%d: %d\n",i++,W+1)){for(j=0;j<C;j++)scanf("%d%d",&A[j],&B[j]);for(W--,j=C-1;j+1;j--)W=W<A[j]+B[j]-1?W<B[j]?W=A[j]+W-1:W-B[j]:W;}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment