結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-13 20:40:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 1,329 bytes |
| コンパイル時間 | 1,389 ms |
| コンパイル使用メモリ | 169,420 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-28 01:45:25 |
| 合計ジャッジ時間 | 1,817 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:39:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
39 | auto [sp_h, sp_m] = parser(sp);
| ^
main.cpp:40:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
40 | auto [wu_h, wu_m] = parser(wu);
| ^
main.cpp: In function 'std::pair<int, int> parser(std::string)':
main.cpp:26:17: warning: 'h' may be used uninitialized [-Wmaybe-uninitialized]
26 | return {h, m};
| ^
main.cpp:14:9: note: 'h' was declared here
14 | int h, m;
| ^
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
pair<int, int> parser(string s){
int h, m;
string tmp = "";
for(int i = 0; i < s.size(); i++){
if(s[i] == ':'){
h = stoi(tmp);
tmp = "";
continue;
}
tmp += (""s + s[i]);
}
m = stoi(tmp);
return {h, m};
}
int main(){
int n;
cin >> n;
int ans = 0;
for(int i = 0; i < n; i++){
string sp, wu;
cin >> sp >> wu;
auto [sp_h, sp_m] = parser(sp);
auto [wu_h, wu_m] = parser(wu);
if(sp_h < wu_h){
ans += (wu_h - sp_h - 1)*60 + (60 - sp_m) + wu_m;
}
else if(sp_h == wu_h){
if(sp_m <= wu_m) ans += (wu_m - sp_m);
else ans += 23*60 + (60 - sp_m) + wu_m;
}
else{
ans += (24 - sp_h - 1)*60 + (60 - sp_m) + wu_h*60 + wu_m;
}
}
cout << ans << endl;
}