difask's blog

By difask, history, 9 years ago, translation, In English

Hello everyone!

Please, help me to solve this problem. I've thought about it with my friends for a long time, but we couldn't find the solution.

You're given N<50 planks with known lengths a[i]<10000. You can cut them in any amount of planks you want. Also you're given planks that you should get. Their amount M<1024, length b[i]<128. You should find maximal number of planks that you can get.

Example:
Input:
4
30 40 50 25
10
15 16 17 18 19 20 21 25 24 30
Output:
7
Explanation:
15 + 16 + 17 -> 50 (cutting 50 into 15, 16, 17, 50-15-16-17=2)
18 + 19 -> 40
20 -> 30
21 -> 25

Thanks!

P.S. I'm currently preparing for my English exam and want to improve my writing. If you notice any mistakes, please send a message or write in the comments section. Thanks!

Full text and comments »

  • Vote: I like it
  • +30
  • Vote: I do not like it

By difask, 9 years ago, In English

Hello! I've found a lot of implementations on the internet. But I don't know which one should I remember. Can you give me your implementation? Thank you.

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

By difask, 10 years ago, In English

Hello everyone!

For some month I was learning algorithms and how to write simple console applications. Today I want to start learning visual programming. I want to appeal to you, cool programmers. How do you recommend to start learning? Which IDE you use and why? What books(websites) you recommend to read(visit) me in the beginning? How did you start? What were your first programs?

Thank you very much!

Full text and comments »

Tags oop
  • Vote: I like it
  • +9
  • Vote: I do not like it

By difask, 10 years ago, In English

I have problem with implementing this algorithm. I know how to implement it if graph doesn't contain multiple edges and self edges. But now I'm trying with them. I know it's not hard. But it gives me WA. I don't know why. My code . Please help!!! Thanks!

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By difask, 10 years ago, In English

I have an interesting problem on data structures.

We're given an array a[1..n]. Also we're given queries l,r,m and it means that min(a[l]..a[r])=m. We should restore array a.

How to solve? Thank you!

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By difask, 10 years ago, translation, In English

I've tried to find, but I couldn't. Is it possible to add group of people to mashup contest? Thank you!

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By difask, 10 years ago, In English

Thanks Gassa for help. The working variant is such:

#define file "taskname"	
#ifdef ONLINE_JUDGE
#define in \
        //file name in task
	freopen(file".in", "r", stdin); \
	freopen(file".out", "w", stdout);
#else
#define in \
        //your file if you use files as input
	freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout); 
#endif

int main()
{
   in;
}

It will make your code for I/O shorter.

Full text and comments »

  • Vote: I like it
  • +10
  • Vote: I do not like it

By difask, 10 years ago, In English

Hello! Is it possible to use something like "bits/stdc++.h" in Visual Studio? For those who mightn't know, "bits\stdc++.h" includes many headers, like iostream,algorithm,cstdio,cstdlib,vector and much more. Thank you!

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By difask, 10 years ago, In English

Hello! I've tried to come up with the solution for next problem but I can't. Please help! Problem: we have an array used, in the beginning used[i]=false for all i. And we are given queries: an index i. We should find the smallest index k of array such that used[k]=false and k>=i. For each query we should find this k and after each query do used[i]=true. Thanks for help!

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By difask, 10 years ago, In English

Sometimes it happens that I solve the problem and I have tests, but I can't find problem on the internet. So I need a tester that can test my solution on tests. I tried to find it on the internet, but I can't. I will appreciate if you give me such program. Thank you!

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By difask, 10 years ago, In English

I think it's really useful and interesting question. How much time per day(week) you spend for programming and how much tasks(themes, articles) you solve(learn, read)?

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it

By difask, 10 years ago, In English

Today I read about treap(cartesian tree). It is mix of tree and heap. And I have a question. Can we implement it through arrays? If such way exists please give me link on implementation. It will be better if it will be in C++. But any other language will be good too. Thank you!

Full text and comments »

  • Vote: I like it
  • +11
  • Vote: I do not like it

By difask, 10 years ago, In English

You are given N points (N <= 20). Distance between 2 points is abs(x1-x2)+abs(y1-y2). You should find the shortest way which will visit all points. You can start from any point.

Full text and comments »

  • Vote: I like it
  • -20
  • Vote: I do not like it

By difask, 10 years ago, In English

Hello everyone! Some days ago I noticed one very useful trick in C++. It works in GNU. I think it will work in VS too. Many coders use macro "#define INF 1000000007", as very large number, larger then possible answer. I notice that instead of writing it, we can write INFINITY and it will the maximal of current type. For example:

  1. ll ans = INFINITY; //long_long_max

  2. if (smth < INFINITY) //int_max by default

  3. if (smth < (long long)INFINITY) //long_long_max

I have never seen it in codes. Maybe for someones it will be useful.

Full text and comments »

  • Vote: I like it
  • +35
  • Vote: I do not like it

By difask, 10 years ago, translation, In English

I have seen in many codes that structure like following is using :

#ifdef something

...

#endif

Where can I set up "something"? I use CodeBlocks. Thank you!

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By difask, 10 years ago, In English

Hello everyone! Please, help me to solve dp problem. We have matrix n*m and house a*b. On some cells there are trees. So we cannot build house on trees. We should count how many ways exist to build one house.

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it