Submission #515766
Source Code Expand
#include <iostream> #include <iomanip> #include <string> using namespace std; int main(){ int n; cin >> n; string x[n]; int s[n], e[n]; for(int i = 0; i < n; i++){ cin >> x[n]; s[n] = stoi(x[n].substr(0,4)); e[n] = stoi(x[n].substr(5,4)); s[n] = s[n] - (s[n] % 5); e[n] = e[n] + 5 - (e[n] % 5); } int as[n], ae[n], c; as[0] = 2400; for(int j = 0; j < n; j++){ for(int i = 0; i < n; i++){ if(j >= 1 && s[i] > ae[j - 1]){ if(s[i] < as[j]){ as[j] = s[i]; c = i; } } } if(as[j] == 0) break; ae[j] = e[c]; for(int i = 0; i < n; i++){ if(s[i] <= ae[j]){ if(e[i] > ae[j]) ae[j] = e[i]; } } } for(int i = 0; as[i] != 0 && i < n; i++){ cout << setw(4) << setfill("0") << as[i]; cout << "-"; cout << setw(4) << ae[i] << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | warahiko |
Language | C++11 (GCC 4.8.1) |
Score | 0 |
Code Size | 859 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:43:8: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’ cout << setw(4) << setfill("0") << as[i]; ^ In file included from /usr/include/c++/4.8/iostream:39:0, from ./Main.cpp:1: /usr/include/c++/4.8/ostream:602:5: error: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::_Setfill<const char*>]’ operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) ^