답안 #560521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
560521 2022-05-11T15:21:36 Z Tien_Noob Exhibition (JOI19_ho_t2) C++17
0 / 100
0 ms 212 KB
//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
#define Log2(x) 31 - __builtin_clz(x)
using namespace std;
const int N = 1e5;
pair<int, int> a[N + 1];
int n, m, c[N + 1], e[N + 1];
void read()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 1; i <= m; ++ i)
    {
        cin >> c[i];
        e[i] = -1;
    }
    sort(c + 1, c + m + 1, greater<int> ());
    sort(a + 1, a + n + 1, [](pair<int, int> x, pair<int, int> y)
         {
             return x > y;
         });
}
void solve()
{
    int res = 0;
    int j = 1;
    for (int i = 1; i <= n; ++ i)
    {
        while(j <= m && c[j] >= a[i].first)
        {
            ++j;
        }
        if (j == 1)
        {
            continue;
        }
        int k = lower_bound(e + 1, e + m + 1, a[i].second) - e - 1;
        k = min(m - k + 1, j - 1);
        res = max(res, k);
        k = m - k + 1;
        e[k] = max(e[k], a[i].second);
    }
    for (int i = 1; i <= m; ++ i)
    {
        cerr << e[i] << ' ';
    }
    cerr << '\n';
    cout << res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen(TASK".INP", "r"))
    {
        freopen(TASK".INP", "r", stdin);
        //freopen(TASK".OUT", "w", stdout);
    }
    int t = 1;
    bool typetest = false;
    if (typetest)
    {
        cin >> t;
    }
    for (int __ = 1; __ <= t; ++ __)
    {
        //cout << "Case " << __ << ": ";
        read();
        solve();
    }
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -