CSES - KILO 2015 0/5 - Results
Submission details
Task:Elevator Trouble
Sender: >--) ) ) )*>
Submission time:2015-09-02 18:51:58 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.05 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.05 sdetails
#6ACCEPTED0.05 sdetails
#7ACCEPTED0.06 sdetails
#8ACCEPTED0.05 sdetails
#9ACCEPTED0.06 sdetails
#10ACCEPTED0.05 sdetails
#11ACCEPTED0.05 sdetails
#12ACCEPTED0.05 sdetails

Code

#include <iostream>

using namespace std;

#define ll long long

int main()
{
	cin.sync_with_stdio(false);
	ll f,s,g,u,d;
	cin >> f >> s >> g >> u >> d;
	if (u == 0 && d == 0) {
		if (s != g) cout << "use the stairs\n";
		else cout << 0 << "\n";
	} else if (u == 0) {
		if (g > s || (s-g)%d != 0) cout << "use the stairs\n";
		else cout << (s-g)/d << "\n";
	} else if (d == 0) {
		if (g < s || (g-s)%u != 0) cout << "use the stairs\n";
		else cout << (g-s)/u << "\n";
	} else {
		ll t = u-d;
		if (g > s) {
			if ((g-s)%u != t) cout << "use the stairs\n";
			else cout << (g-s)/u + 2*((g-s)%u) << "\n";
		} else if (g < s) {
			if ((s-g)%d != t) cout << "use the stairs\n";
			else cout << (s-g)/d + 2*((s-g)%d) << "\n";
		} else {
			cout << 0 << "\n";
		}
	}
}

Test details

Test 1

Verdict: ACCEPTED

input
10 1 10 2 1

correct output
6

user output
6

Test 2

Verdict: ACCEPTED

input
100 2 1 1 0

correct output
use the stairs

user output
use the stairs

Test 3

Verdict: ACCEPTED

input
1000000 1 1000000 1 1

correct output
999999

user output
999999

Test 4

Verdict: ACCEPTED

input
1000000 1 1000000 0 1

correct output
use the stairs

user output
use the stairs

Test 5

Verdict: ACCEPTED

input
1000000 1 1000000 0 0

correct output
use the stairs

user output
use the stairs

Test 6

Verdict: ACCEPTED

input
1000000 1 1000000 1 0

correct output
999999

user output
999999

Test 7

Verdict: ACCEPTED

input
1000000 1000000 1 0 1

correct output
999999

user output
999999

Test 8

Verdict: ACCEPTED

input
1000000 2 99999 2 1

correct output
50000

user output
50000

Test 9

Verdict: ACCEPTED

input
10 5 4 6 2

correct output
use the stairs

user output
use the stairs

Test 10

Verdict: ACCEPTED

input
1000000 1000000 1000000 100000...

correct output
0

user output
0

Test 11

Verdict: ACCEPTED

input
456789 2 456789 2 1

correct output
228395

user output
228395

Test 12

Verdict: ACCEPTED

input
100 50 51 4 6

correct output
use the stairs

user output
use the stairs