835A - Key races - CodeForces Solution


math *800

Please click on ads to support us..

Python Code:

s, v1, v2, t1, t2 = map(int, input().split())
c1 = (s * v1) + t1 * 2
c2 = (s * v2) + t2 * 2
if c1 < c2:
    print('First')
elif c2 < c1:
    print('Second')
else:
    print('Friendship')

C++ Code:

	#include <bits/stdc++.h>
	#define ll long long
	#define fast()  ios_base::sync_with_stdio (false); cin.tie (0); cout.tie (0);
	#define run() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	#define st string
	#define forx for (ll i = 0; i < x; i++)
	#define fork for (ll i = 0; i < k; i++)
	#define fory for (ll i = 0; i < y; i++)
	#define wh while
	#define ms multiset
	#define rs reverse
	#define ss stringstream
	#define dbl double
	#define fors for(ll i = 0; i < s.size();i++)
	#define forn for(ll i = 0; i < n;i++)
	#define form for(ll j = 0; j <= m;j++)
	#define pb push_back 
	#define rt0 return 0;
	const int Max = 1e9;
	#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
	#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
	#pragma GCC optimize("Ofast")
	#pragma GCC target("avx,avx2,fma")
	#pragma GCC optimization("unroll-loops")
	#pragma ("reroll")
	const int N = 1e5 + 1;
	ll n,m,a[N], cnt = 0, mx = Max, mn = Max;
	using namespace std;
	int main()
	{
	 run()
	 fast()
	 ll s,v1,v2,t1,t2;
	 cin>>s>>v1>>v2>>t1>>t2;
	 if((s*v1)+(t1*2) < (s*v2)+(t2*2)){
	     cout<<"First";
	 }
	 else if((s*v1)+(t1*2) > (s*v2)+(t2*2)){
	     cout<<"Second";
	 }
	 else cout<<"Friendship";
	}


Comments

Submit
0 Comments
More Questions

1302. Deepest Leaves Sum
1209. Remove All Adjacent Duplicates in String II
994. Rotting Oranges
983. Minimum Cost For Tickets
973. K Closest Points to Origin
969. Pancake Sorting
967. Numbers With Same Consecutive Differences
957. Prison Cells After N Days
946. Validate Stack Sequences
921. Minimum Add to Make Parentheses Valid
881. Boats to Save People
497. Random Point in Non-overlapping Rectangles
528. Random Pick with Weight
470. Implement Rand10() Using Rand7()
866. Prime Palindrome
1516A - Tit for Tat
622. Design Circular Queue
814. Binary Tree Pruning
791. Custom Sort String
787. Cheapest Flights Within K Stops
779. K-th Symbol in Grammar
701. Insert into a Binary Search Tree
429. N-ary Tree Level Order Traversal
739. Daily Temperatures
647. Palindromic Substrings
583. Delete Operation for Two Strings
518. Coin Change 2
516. Longest Palindromic Subsequence
468. Validate IP Address
450. Delete Node in a BST