670A - Holidays - CodeForces Solution


brute force constructive algorithms greedy math *900

Please click on ads to support us..

Python Code:

days = int(input())

if days < 7:
  if days == 6:
    print(1,2)
  elif days <= 5 and days > 1:
    print(0,2)
  else:
    print(0,1)

else:
  
  m1 = days % 7     m2 = days // 7  
  if m1 >= 2:
    maxs = m2 * 2 + 2
  elif m1 == 1:
    maxs = m2 * 2 + 1
  else:
    maxs = m2 * 2

  m3 = m2 * 2
  if m1 == 5:
    print(m3,maxs)
  else:
    mins = m3 + m1 // 5
    print(mins,maxs)

C++ Code:

#include<bits/stdc++.h>
using namespace std;

int n,maxans,minans;
 
int main() 
{
	while(scanf("%d",&n)==1)
	{
		minans=maxans=(n+6)/7*2;
		if(n%7>=1&&n%7<=5)minans=maxans-2;
		if(n%7==6)minans=maxans-1;
		if(n%7==1)maxans--;
		printf("%d %d\n",minans,maxans);	
	}
	return 0;
}


Comments

Submit
0 Comments
More Questions

1673A - Subtle Substring Subtraction
1345A - Puzzle Pieces
711A - Bus to Udayland
779B - Weird Rounding
1703D - Double Strings
1704C - Virus
63A - Sinking Ship
1704B - Luke is a Foodie
298B - Sail
239A - Two Bags of Potatoes
1704E - Count Seconds
682A - Alyona and Numbers
44A - Indian Summer
1133C - Balanced Team
1704A - Two 0-1 Sequences
1467A - Wizard of Orz
1714E - Add Modulo 10
1714A - Everyone Loves to Sleep
764A - Taymyr is calling you
1714B - Remove Prefix
1264F - Beautiful Fibonacci Problem
52A - 123-sequence
1543A - Exciting Bets
1714D - Color with Occurrences
215B - Olympic Medal
1445A - Array Rearrangment
1351A - A+B (Trial Problem)
935B - Fafa and the Gates
1291A - Even But Not Even
1269A - Equation