結果

問題 No.70 睡眠の重要性!
ユーザー testtest
提出日時 2020-09-04 14:56:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 925 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 168,844 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 21:28:50
合計ジャッジ時間 2,188 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 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