結果

問題 No.70 睡眠の重要性!
ユーザー kaito_tateyamakaito_tateyama
提出日時 2017-08-08 05:52:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 983 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 68,012 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 04:10:16
合計ジャッジ時間 1,271 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <fstream>

using namespace std;

vector<string> split(const string& input, char delimiter) {
    istringstream stream(input);

    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
      result.push_back(field);
    }
    return result;
}

int main() {


  int n,sum;
  sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string x,y;
    cin >> x >> y;
    //xをsplitしてそれぞれ出力
    //cout << split(x, ':')[1] << "\n";

    int hx = stoi(split(x,':')[0]);
    int mx = stoi(split(x,':')[1]);
    int hy = stoi(split(y,':')[0]);
    int my = stoi(split(y,':')[1]);
    //cout << hx << "\n";
    int st = hx * 60 + mx;
    int en = hy * 60 + my;
    //cout << hx << " " << st << "\n";
    if(en - st < 0){
      sum += 1440 + en - st;
    }else{
      sum += en - st;
    }
    //cout << sum << "\n";
  }
  cout << sum << "\n";

  return 0;
}
0