Submission #515763


Source Code Expand

#include <iostream>
#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 839 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:42:17: error: ‘setw’ was not declared in this scope
   cout << setw(4) << setfill("0") << as[i];
                 ^
./Main.cpp:42:33: error: ‘setfill’ was not declared in this scope
   cout << setw(4) << setfill("0") << as[i];
                                 ^