結果
| 問題 | No.70 睡眠の重要性! | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-09-10 14:30:26 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,196 bytes | 
| コンパイル時間 | 1,730 ms | 
| コンパイル使用メモリ | 174,992 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-02 16:15:31 | 
| 合計ジャッジ時間 | 2,232 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 6 | 
ソースコード
/**
  @file 070.cpp
  @title  No.70 睡眠の重要性! - yukicoder
  @url https://yukicoder.me/problems/no/70
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)
vector<string> split(string S) {
  auto separator        = string(":");
  auto separator_length = separator.length();
  auto list = vector<string>();
  auto offset = string::size_type(0);
  while (1) {
    auto pos = S.find(separator, offset);
    if (pos == string::npos) {
      list.push_back(S.substr(offset));
      break;
    }
    list.push_back(S.substr(offset, pos - offset));
    offset = pos + separator_length;
  }
  return list;
}
int main() {
  int N;
  cin >> N;
  vector<pair<string, string>> time(N, make_pair("", ""));
  REP(i, N) {
    cin >> time[i].first >> time[i].second;
  }
  LL sleep{0};
  REP(i, N) {
    auto neru  = split(time[i].first);
    auto okiru = split(time[i].second);
    LL s0 = (stoi(neru[0]) * 60 + stoi(neru[1]));
    LL s1 = (stoi(okiru[0]) * 60 + stoi(okiru[1]));
    sleep += s1 - s0 >= 0 ? s1 - s0 : s1 + 24 * 60 - s0;
  }
  cout << sleep << endl;
  return 0;
}
            
            
            
        