Submission #140580

#TimeUsernameProblemLanguageResultExecution timeMemory
140580khrbuddy03공주님의 정원 (KOI11_flower)C++14
18 / 18
56 ms3440 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...