답안 #1114641

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114641 2024-11-19T09:49:39 Z AdamGS Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
297 ms 17992 KB
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;

int main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);

    i64 N;
    cin >> N;

    vector<pair<i64, i64>> tie(N + 1);
    for (i64 i = 0; i <= N; i++)
    {
        cin >> tie[i].first;
        tie[i].second = i;
    }
    sort(tie.begin(), tie.end());

    vector<i64> emp(N);
    for (i64 i = 0; i < N; i++)
    {
        cin >> emp[i];
    }
    sort(emp.begin(), emp.end());

    multiset<i64> akt;
    vector<i64> wynik(N + 1);
    for (i64 i = 1; i <= N; i++)
    {
        akt.insert(max(tie[i].first - emp[i - 1], (i64)0));
    }
    auto it = akt.end(); it--;
    wynik[tie[0].second] = *it;

    for (i64 i = 1; i <= N; i++)
    {
        auto it = akt.find(max((i64)0, tie[i].first - emp[i - 1]));
        akt.erase(it);
        akt.insert(max((i64)0, tie[i - 1].first - emp[i - 1]));
        auto it2 = akt.end(); it2--;
        wynik[tie[i].second] = *it2;
    }

    for (i64 i = 0; i < wynik.size(); i++)
    {
        cout << wynik[i] << ' ';
    }
    cout << "\n";

    return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:46:23: warning: comparison of integer expressions of different signedness: 'i64' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (i64 i = 0; i < wynik.size(); i++)
      |                     ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 396 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 396 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 504 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 3 ms 464 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 4 ms 592 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 2 ms 760 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 3 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 396 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 504 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 3 ms 464 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 4 ms 592 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 2 ms 760 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 3 ms 592 KB Output is correct
33 Correct 202 ms 16724 KB Output is correct
34 Correct 236 ms 17380 KB Output is correct
35 Correct 231 ms 16972 KB Output is correct
36 Correct 247 ms 17480 KB Output is correct
37 Correct 246 ms 17992 KB Output is correct
38 Correct 228 ms 17736 KB Output is correct
39 Correct 282 ms 16712 KB Output is correct
40 Correct 261 ms 16516 KB Output is correct
41 Correct 275 ms 16712 KB Output is correct
42 Correct 260 ms 16712 KB Output is correct
43 Correct 253 ms 16712 KB Output is correct
44 Correct 194 ms 16204 KB Output is correct
45 Correct 195 ms 16244 KB Output is correct
46 Correct 195 ms 16200 KB Output is correct
47 Correct 190 ms 16456 KB Output is correct
48 Correct 207 ms 16456 KB Output is correct
49 Correct 276 ms 17224 KB Output is correct
50 Correct 291 ms 17112 KB Output is correct
51 Correct 271 ms 17224 KB Output is correct
52 Correct 297 ms 17124 KB Output is correct
53 Correct 269 ms 17232 KB Output is correct