Submission #140580

# Submission time Handle Problem Language Result Execution time Memory
140580 2019-08-03T15:51:33 Z khrbuddy03 공주님의 정원 (KOI11_flower) C++14
18 / 18
56 ms 3440 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> day;
typedef pair<day, day> flower;

bool in(const flower& f, const day& d) {
	if (f.first <= d && d <= f.second) return true;
	return false;
}

int p = 0, ans = 0, month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	vector<flower> flowers;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		flowers.emplace_back(day(a, b), day(c, d));
	}
	day end(3, 0);
	sort(flowers.begin(), flowers.end());
	for (int i = 3; i < 12; i++) {
		for (int j = 1; j < month[i] + 1; j++) {
			day today(i, j);
			if (end <= today) {
				bool ok = false;
				int np = 0;
				for (int k = p; k < n; k++) {
					if (in(flowers[k], today)) {
						ok = true;
						if (end < flowers[k].second) {
							end = flowers[k].second;
							np = k;
						}
					}
				}
				if (!ok) {
					cout << "0\n";
					return 0;
				}
				p = np + 1;
				ans++;
			}
		}
	}
	cout << ans << '\n';
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 312 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 4 ms 636 KB Output is correct
6 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 888 KB Output is correct
2 Correct 11 ms 1144 KB Output is correct
3 Correct 17 ms 1268 KB Output is correct
4 Correct 20 ms 1908 KB Output is correct
5 Correct 26 ms 2088 KB Output is correct
6 Correct 29 ms 2036 KB Output is correct
7 Correct 34 ms 3184 KB Output is correct
8 Correct 49 ms 3440 KB Output is correct
9 Correct 56 ms 3436 KB Output is correct
10 Correct 47 ms 3440 KB Output is correct