Advertisement
a53

turism

a53
Oct 16th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #define DIM 110
  3.  
  4. long V[DIM];
  5. long n,m,k,d,c,i,max,poz,cost,pas,rez;
  6.  
  7. int main() {
  8. FILE *f = fopen("turism.in","r");
  9. fscanf(f,"%ld%ld%ld",&n, &k, &m);
  10. for (pas=1;pas<=m;pas++) {
  11. for (i=1;i<=k;i++)
  12. if (V[i])
  13. V[i]--;
  14.  
  15. fscanf(f,"%ld",&d);
  16. poz = 1;
  17. for (i=1;i<=d;i++) {
  18. fscanf(f,"%ld",&c);
  19. while (poz<=k && V[poz])
  20. poz++;
  21. if (poz<=k) {
  22. V[poz] = c;
  23. cost += c;
  24. }
  25. }
  26. }
  27. max = V[1];
  28. for (i=2;i<=k;i++)
  29. if (V[i]>max)
  30. max = V[i];
  31. fclose(f);
  32.  
  33. rez = (m-1)/n+1;
  34. if (max)
  35. rez+=((max-m%n-1)/n+1);
  36. // rez+=((max-1)/n+1);
  37.  
  38. FILE *g = fopen("turism.out","w");
  39. fprintf(g,"%ld %ld",cost,rez);
  40. fclose(f);
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement