Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Problem: http://code.google.com/codejam/contest/dashboard?c=351101#s=p0
- */
- #include<stdio.h>
- #include<stdlib.h>
- int main(int argc, char **argv)
- {
- int n, c, i, p; //cases, credit, item, price
- int *items = 0;
- int case_no = 1;
- for(scanf("%d",&n); n; n--)
- {
- scanf("%d%d",&c,&i);
- if(items)
- free(items);
- items = (int *)malloc(sizeof(int) * i);
- int a,b; //tmp vats
- for(a = 0; a < i && scanf("%d",&p);a++)
- items[a] = p;
- //process
- int done = 0;
- for(a = 0; a < i && !done; a++)
- for(b = a+1; b < i && !done; b++)
- if(items[a]+items[b] == c)
- {
- printf("Case #%d: %d %d\n",case_no++,a+1,b+1);
- done = 1;
- }
- }
- if(items)
- free(items);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement