結果

問題 No.70 睡眠の重要性!
ユーザー siguma323siguma323
提出日時 2016-05-09 21:17:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,264 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 87,348 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 14:57:38
合計ジャッジ時間 1,266 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <list>
#include <map>
#include <queue>
#include <iterator>
#include <cmath>
#include <iomanip>
using namespace std;

using ull = unsigned long long;
using ll = long long;

pair<int,int> getHS(string data)
{
    pair<int,int>  rtn;
    for(int i =0; i < data.size(); ++i)
    {
        if(data.at(i) == ':')
        {
            rtn.first = stoi(data.substr(0,i));
            rtn.second = stoi(data.substr(i+1));
            break;
        }
    }

    return rtn;
}

int main()
{
    int n;
    cin >> n;
    vector<string> a(n);
    vector<string> b(n);

    for(int i =0; i < n; ++i)
    {
        cin >> a.at(i);
        cin >> b.at(i);
    }

    int sum = 0;
    for(int i =0; i < n; ++i)
    {
        pair<int,int> first;
        pair<int,int> second;
        first = getHS(a.at(i));
        second = getHS(b.at(i));

        sum += (60-first.second + second.second);

        int sub = second.first - first.first - 1;
        if(sub >= -1)
        {
            sum += sub * 60;
        }
        else
        {
            sum += (24 + sub) * 60;
        }
    }

    cout << sum << endl;
}
0