結果

問題 No.70 睡眠の重要性!
ユーザー ゆうPゆうP
提出日時 2024-04-07 00:03:20
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 786 bytes
コンパイル時間 12,317 ms
コンパイル使用メモリ 212,676 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-07 00:03:33
合計ジャッジ時間 12,797 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.70 睡眠の重要性!
package main

import (
	"fmt"
	"strconv"
	"strings"
	"time"
)

func main() {
	var n int
	fmt.Scan(&n)

	type Sleep struct {
		Gbed string
		Wake string
	}
	rec := make([]Sleep, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&rec[i].Gbed, &rec[i].Wake)
	}

	var hh, mm string
	var h1, h2, m1, m2 int
	var ans float64
	for _, r := range rec {
		hh, mm, _ = strings.Cut(r.Gbed, ":")
		h1, _ = strconv.Atoi(hh)
		m1, _ = strconv.Atoi(mm)

		hh, mm, _ = strings.Cut(r.Wake, ":")
		h2, _ = strconv.Atoi(hh)
		m2, _ = strconv.Atoi(mm)

		gt := time.Date(1, 1, 1, h1, m1, 0, 0, time.Now().Location())
		wt := time.Date(1, 1, 1, h2, m2, 0, 0, time.Now().Location())
		if gt.After(wt) {
			wt = wt.AddDate(0, 0, 1)
		}
		ans += wt.Sub(gt).Minutes()
	}
	fmt.Println(ans)
}
0