I wanted to solve NOMURA Contest 2020 with Python

Introduction

long time no see. I was so busy with school tasks that I couldn't devote myself (excuse) It was a complete A and B. Moreover, I grew one pena each.

A problem

Problem

** Thoughts ** When $ m1> m2 $, it cannot be subtracted as it is, so 1 is fetched from $ h1 $.

h1, m1, h2, m2, k = map(int,input().split())

if m1 > m2:
    m2 += 60
    h2 -=1
    ans_m = m2 - m1
else:
    ans_m = m2 - m1

ans_h = h2 - h1
ans = 60 * ans_h + ans_m

print(ans-k)

I made a mistake in the order of subtraction and made 1WA. Mottainai

B problem

Problem

** Thoughts ** ~~ Hitachikon's nightmare comes back ~~, I'm not good at this kind of problem. It's best to set everything to D, but I didn't notice it, so I'm pushing it with an if statement.

t = list(input())
n = len(t)

if t[0] == '?':
    if n > 1:
        if t[1] == '?':
            t[0] = 'P'
        else:
            t[0] = 'D'
    else:
        t[0] = 'D'
if t[-1] == '?':
    t[-1] = 'D'
for i in range(1,n-1):
    if t[i] == '?':
        if t[i-1] == 'P':
            t[i] = 'D'
        else:
            if t[i+1] == '?' or t[i+1] == 'D':
                t[i] = 'P'
            else:
                t[i] = 'D'

ans = ''.join(t)
print(ans)

Summary

It was cool if I could solve C. I'm worried about ABC tomorrow. See you again, good night.

Recommended Posts

I wanted to solve NOMURA Contest 2020 with Python
I wanted to solve ABC160 with Python
I wanted to solve ABC172 with Python
I wanted to solve the Panasonic Programming Contest 2020 with Python
I wanted to solve ABC159 in Python
I wanted to solve the ABC164 A ~ D problem with Python
I wanted to install Python 3.4.3 with Homebrew + pyenv
I want to solve APG4b with Python (Chapter 2)
I tried to solve the soma cube with python
I tried to solve the problem with Python Vol.1
I tried to solve AOJ's number theory with Python
I want to debug with Python
I want to analyze logs with Python
I want to play with aws with python
I tried to solve TSP with QAOA
I really wanted to copy with selenium
I tried to solve the ant book beginner's edition with python
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
Solve AtCoder 167 with python
I want to use MATLAB feval with python
How to write offline real time I tried to solve E11 with python
Try to solve the man-machine chart with Python
I want to make a game with Python
I wanted to play with the Bezier curve
I tried to get CloudWatch data with Python
I tried to output LLVM IR with Python
Solve Sudoku with Python
It's more recent, but I wanted to do BMI calculation with python.
I want to use Temporary Directory with Python2
I tried to automate sushi making with python
#Unresolved I want to compile gobject-introspection with Python3
Solve POJ 2386 with python
I want to write to a file with Python
How to write offline real time I tried to solve E12 with python
I wanted to visualize 3D particle simulation with the Python visualization library Matplotlib.
Try to solve the programming challenge book with python3
I also wanted to check type hints with numpy
I want to handle optimization with python and cplex
I tried to implement Minesweeper on terminal with python
I tried to get started with blender python script_Part 01
Try to solve the internship assignment problem with Python
I tried to touch the CSV file with Python
I tried to draw a route map with Python
I tried to get started with blender python script_Part 02
I wanted to use the Python library from MATLAB
I was addicted to scraping with Selenium (+ Python) in 2020
I tried to implement an artificial perceptron with python
I want to inherit to the back with python dataclass
I want to work with a robot in python.
I tried to automatically generate a password with Python3
I want to AWS Lambda with Python on Mac!
[ML Ops] I want to do multi-project with Python
I tried to analyze J League data with Python
I want to run a quantum computer with Python
[Python] Solve equations with sympy
I tried fp-growth with python
I tried scraping with Python
Connect to BigQuery with Python
Solve AtCoder ABC166 with python
I made blackjack with python!
Connect to Wikipedia with Python