結果

問題 No.70 睡眠の重要性!
ユーザー testtest
提出日時 2020-09-04 14:56:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 925 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 170,988 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 04:52:08
合計ジャッジ時間 1,928 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

std::vector<int> split_int(std::string src, char delimiter) {
  int first = 0;
  int last = src.find_first_of(delimiter);
  std::vector<int> result;
  while (first < src.size()) {
    std::string subStr(src, first, last - first);
    result.emplace_back(std::stoi(subStr));
    first = last + 1;
    last = src.find_first_of(delimiter, first);
    if (last == std::string::npos) {
      last = src.size();
    }
  }
  return result;
}

int main() {
  int N;
  int ans = 0;
  string s;
  cin >> N;
  vector<int> vs, ve;
  int ts, te;
  const int h24 = 24 * 60;
  rep(i, 0, N) {
    cin >> s;
    vs = split_int(s, ':');
    cin >> s;
    ve = split_int(s, ':');

    ts = vs[0] * 60 + vs[1];
    te = ve[0] * 60 + ve[1];

    if (ts > te) {
      te += h24;
    }

    ans += te - ts;
  }
  cout << ans << endl;
  getchar();
}
0