[ create a new paste ] login | about

Link: http://codepad.org/u2exld9Q    [ raw code | output | fork ]

hoaithu.melody - C++, pasted on Mar 9:
//Flatten
//cho nhieu cot co do cao khac nhau, chuyen lan luot tung o tu cot cao nhat den cot thap nhat. sau dump lan chuyen, xuat ra hieu cao nhat - thap nhat
#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
	int dump;
	int boxes[100];

	freopen("Testcase.txt", "r", stdin);
	for(int testcase = 1; testcase <= 10; testcase++)
	{
		int i, d;
		cin >> dump;
		for(i = 0; i < 100; i++)
			cin >> boxes[i];

		while(dump >= 0)
		{
			int max = 1, min = 100;
			int posMax = 0, posMin = 0;
			for(i = 0; i < 100; i++)
			{
				if(max < boxes[i])
				{
					max = boxes[i];
					posMax = i;
				}
				if(min > boxes[i])
				{
					min = boxes[i];
					posMin = i;
				}
			}
			if(dump == 0)
			{
				d = max - min;
			}
			else
			{
				boxes[posMax]--;
				boxes[posMin]++;
			}
			dump--;
		}

		cout << "#" << testcase << " " << d << endl;
	}
	getch();
	return 0;
}


Output:
1
2
3
4
Line 18: error: conio.h: No such file or directory
In function 'int main()':
Line 52: error: 'getch' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: