diff --git a/fnhid/AdHoc/1813.cpp b/fnhid/AdHoc/1813.cpp new file mode 100644 index 0000000..bea3353 --- /dev/null +++ b/fnhid/AdHoc/1813.cpp @@ -0,0 +1,28 @@ +#include +#include +using namespace std; + +int main() +{ + int n, t; + cin >> n; + vector a(51, 0); + for(int i=0;i> t; + a[t]++; + } + + for(int i=50;i>0;i--){ + if(a[i]==i) { + cout << i; + return 0; + } + } + + if(a[0]==0) cout << 0; + else cout << -1; + + return 0; + + +} \ No newline at end of file diff --git a/fnhid/PriorityQueue/1374.cpp b/fnhid/PriorityQueue/1374.cpp new file mode 100644 index 0000000..4eab974 --- /dev/null +++ b/fnhid/PriorityQueue/1374.cpp @@ -0,0 +1,49 @@ +#include +#include +#include +#include + +struct Lecture +{ + long long start, end; +}; + +int max(int a, int b) +{ + return a > b ? a : b; +} + +using namespace std; + +int main() +{ + int n, id, start, end, answer=0; + priority_queue, greater> pq; + + + cin >> n; + vector v(n); + for (int i=0;i> id >> start >> end; + v.push_back({start, end}); + } + + sort(v.begin(), v.end(), [](const Lecture& a, const Lecture& b) + { + return a.start < b.start; + }); + + for (Lecture& l : v) + { + + while (!pq.empty() && pq.top() <= l.start) + pq.pop(); + pq.push(l.end); + answer = max(answer, (int)pq.size()); + } + + + cout << answer; + +} \ No newline at end of file diff --git a/fnhid/README.md b/fnhid/README.md index eaad859..36516fb 100644 --- a/fnhid/README.md +++ b/fnhid/README.md @@ -1,6 +1,12 @@ ## ✏️ 기록 -| 차시 | 날짜 | 문제유형 | 링크 | 풀이 | - |:----:|:----------:|:----------:|:-------------------------------------------:|:---------------------------------------------------:| -| 16차시 | 2025.06.25 | 다이나믹 프로그래밍 | [균형](https://www.acmicpc.net/problem/22968) | https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/64 | +| 차시 | 날짜 | 문제유형 | 링크 | 풀이 | + |:----:|:----------:|:----------:|:------------------------------------------------------------:|:---------------------------------------------------:| +| 16차시 | 2025.06.25 | 다이나믹 프로그래밍 | [균형](https://www.acmicpc.net/problem/22968) | https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/64 | +| 17차시 | 2025.06.27 | KMP 알고리즘 | [찾기](https://www.acmicpc.net/problem/1786) | https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/67 | +| 18차시 | 2025.07.05 | 그래프 | [여러분의 다리가 되어 드리겠습니다!](https://www.acmicpc.net/problem/17352) | https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/73 | +| 19차시 | 2025.07.06 | 큐 | [뱀](https://www.acmicpc.net/problem/3190) | https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/74 | +| 20차시 | 2025.07.12 | 우선순위 큐 | [강의실](https://www.acmicpc.net/problem/1374) | https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/80 | +| 21차시 | 2025.07.14 | 투 포인터 | [좋다](https://www.acmicpc.net/problem/1253) | https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/83 | +| 22차시 | 2025.07.18 | 애드 혹 | [논리학 교수](https://www.acmicpc.net/problem/1813) | https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/86 | \ No newline at end of file diff --git a/fnhid/TwoPointer/1253.cpp b/fnhid/TwoPointer/1253.cpp new file mode 100644 index 0000000..375b0a1 --- /dev/null +++ b/fnhid/TwoPointer/1253.cpp @@ -0,0 +1,44 @@ +#include +#include +#include + +using namespace std; + + +int main() { + cin.sync_with_stdio(false); + cin.tie(NULL); + int n, cnt=0, target, l, r, sum; + + cin >> n; + + vector v(n,0); + + for (int i = 0; i < n; i++) { + cin >> v[i]; + } + sort(v.begin(), v.end()); + + + for (int i = 0; i < n; i++) { + l=0;r=n-1; + target = v[i]; + while (l < r){ + if (l==i) {l++;continue;} + if (r==i) {r--;continue;} + sum=v[r]+v[l]; + if (sum==target) { + cnt++; + break; + } else if (sum < target) { + l++; + } else { + r--; + } + + } + } + + cout << cnt << endl; + return 0; +}