Submission #1549844
Source Code Expand
#include <stdio.h> #include <algorithm> #include <vector> using namespace std; typedef pair<int,int> p; typedef pair<p,p> t; bool comp(const t &a, const t &b){//降順そーと int a_first,a_second,b_first,b_second; a_first = a.first.first*100+a.first.second; b_first = b.first.first*100+b.first.second; a_second = a.second.first*100+a.second.second; b_second = b.second.first*100+b.second.second; return a_first < b_first || (a_first == b_first && a_second < b_second); } int main(){ int n, i; int first, second; char text[10]; vector<t> time; p tmp1; p tmp2; p f; p s; vector<t> answer; int ans_ff, ans_fs, ans_sf, ans_ss; scanf("%d", &n); for(i = 0; i < n; i++){ scanf("%s", text); first = 0; second = 0; for (int j = 0; j < 2; j++) { first *= 10; first += text[j]-'0'; } for (int j = 2; j < 4 ; j++) { second *= 10; second += text[j]-'0'; } if(second % 5 > 0){ second = (second / 5) * 5; } f = make_pair(first, second); first = 0; second = 0; for (int j = 5; j < 7; j++) { first *= 10; first += text[j]-'0'; } for (int j = 7; j < 9; j++) { second *= 10; second += text[j]-'0'; } if(second % 5 > 0){ second = (second / 5 + 1) * 5; } if(second == 60){ second = 0; first++; } s = make_pair(first, second); time.push_back(t(f,s)); } sort(time.begin(),time.end(),comp); ans_ff = time[0].first.first; ans_fs = time[0].first.second; ans_sf = time[0].second.first; ans_ss = time[0].second.second; for(int i = 1; i < n; i++){ if(time[i].first.first < ans_sf || (time[i].first.first == ans_sf && time[i].first.second <= ans_ss)){ if(time[i].second.first > ans_sf || (time[i].second.first == ans_sf && time[i].second.second > ans_ss)){ ans_sf = time[i].second.first; ans_ss = time[i].second.second; } continue; } tmp1 = make_pair(ans_ff,ans_fs); tmp2 = make_pair(ans_sf,ans_ss); answer.push_back(t(tmp1,tmp2)); ans_ff = time[i].first.first; ans_fs = time[i].first.second; ans_sf = time[i].second.first; ans_ss = time[i].second.second; } tmp1 = make_pair(ans_ff,ans_fs); tmp2 = make_pair(ans_sf,ans_ss); answer.push_back(t(tmp1,tmp2)); for(t i : answer){ printf("%02d%02d-%02d%02d\n", i.first.first, i.first.second, i.second.first, i.second.second); } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | puellakume |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 2572 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 892 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:31:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:33:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", text); ^
Judge Result
Set Name | all | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 1 ms | 256 KB |
00_sample_02.txt | AC | 1 ms | 256 KB |
00_sample_03.txt | AC | 1 ms | 256 KB |
cho_cho_chokudai.txt | AC | 6 ms | 892 KB |
chokudai_ga_cho.txt | AC | 7 ms | 892 KB |
test_01.txt | AC | 1 ms | 256 KB |
test_02.txt | AC | 1 ms | 256 KB |
test_03.txt | AC | 1 ms | 256 KB |
test_04.txt | AC | 1 ms | 256 KB |
test_05.txt | AC | 1 ms | 256 KB |
test_06.txt | AC | 1 ms | 256 KB |
test_07.txt | AC | 1 ms | 256 KB |
test_08.txt | AC | 1 ms | 256 KB |
test_09.txt | AC | 1 ms | 256 KB |
test_10.txt | AC | 1 ms | 256 KB |
test_11.txt | AC | 1 ms | 256 KB |
test_12.txt | AC | 1 ms | 256 KB |
test_13.txt | AC | 1 ms | 256 KB |
test_14.txt | AC | 1 ms | 256 KB |
test_15.txt | AC | 1 ms | 256 KB |
test_16.txt | AC | 1 ms | 256 KB |
test_17.txt | AC | 1 ms | 256 KB |
test_18.txt | AC | 1 ms | 256 KB |
test_19.txt | AC | 1 ms | 256 KB |
test_20.txt | AC | 1 ms | 256 KB |
test_21.txt | AC | 8 ms | 892 KB |
test_22.txt | AC | 8 ms | 892 KB |
test_23.txt | AC | 8 ms | 892 KB |
test_24.txt | AC | 8 ms | 892 KB |
test_25.txt | AC | 8 ms | 892 KB |
test_26.txt | AC | 7 ms | 892 KB |
test_27.txt | AC | 6 ms | 892 KB |
test_28.txt | AC | 7 ms | 892 KB |
test_29.txt | AC | 1 ms | 256 KB |
test_30.txt | AC | 1 ms | 256 KB |
test_31.txt | AC | 2 ms | 384 KB |
test_32.txt | AC | 1 ms | 256 KB |
test_33.txt | AC | 5 ms | 892 KB |
test_34.txt | AC | 1 ms | 256 KB |
test_35.txt | AC | 1 ms | 256 KB |
test_36.txt | AC | 8 ms | 892 KB |
test_37.txt | AC | 7 ms | 892 KB |
test_38.txt | AC | 7 ms | 892 KB |
test_39.txt | AC | 7 ms | 892 KB |
test_40.txt | AC | 7 ms | 892 KB |
test_41.txt | AC | 6 ms | 892 KB |
test_42.txt | AC | 6 ms | 892 KB |
test_43.txt | AC | 6 ms | 892 KB |