Submission #1114650

# Submission time Handle Problem Language Result Execution time Memory
1114650 2024-11-19T10:11:46 Z AdamGS Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
94 ms 13676 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,k,odd,index;
    cin >> n;
    vector<pair<int,int>>dostepne_szyje,ciag;
    vector<int>jakie_maja_ludzie;
    vector<int>s(1),p(1);
    for(int i=0;i<n+1;++i){
        cin >> k;
        dostepne_szyje.push_back({k,i+1});
    }
    sort(dostepne_szyje.begin(),dostepne_szyje.end());
    for(int i=0;i<n;++i){
        cin >> k;   
        jakie_maja_ludzie.push_back(k);
    }
    sort(jakie_maja_ludzie.begin(),jakie_maja_ludzie.end());

    for(int i=0;i<n;++i){
        p.push_back(max(p[i],max(dostepne_szyje[i].first-jakie_maja_ludzie[i],0)));
    }
    for(int i=n;i>0;--i){
        s.push_back(max(s[n-i],max(dostepne_szyje[i].first-jakie_maja_ludzie[i-1],0)));
        //cout << s[n-i] << endl;
    }
    for(int i=0;i<p.size();++i){
        //cout << p[i] << ' ';
    }
    //cout << endl;
    for(int i=0;i<s.size();++i){
        //cout << s[i] << ' ';
    }
    //cout << endl;
    for(int i=0;i<n+1;++i){
        ciag.push_back({dostepne_szyje[i].second,max(p[i],s[n-i])});
    }
    sort(ciag.begin(),ciag.end());
    for(int i=0;i<ciag.size();++i){
        cout << ciag[i].second << ' ';
    }
    return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i=0;i<p.size();++i){
      |                 ~^~~~~~~~~
ho_t1.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<s.size();++i){
      |                 ~^~~~~~~~~
ho_t1.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<ciag.size();++i){
      |                 ~^~~~~~~~~~~~
ho_t1.cpp:6:13: warning: unused variable 'odd' [-Wunused-variable]
    6 |     int n,k,odd,index;
      |             ^~~
ho_t1.cpp:6:17: warning: unused variable 'index' [-Wunused-variable]
    6 |     int n,k,odd,index;
      |                 ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Correct 1 ms 336 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 504 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 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Correct 1 ms 336 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 504 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 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 508 KB Output is correct
4 Correct 1 ms 336 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 504 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 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 2 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 84 ms 10144 KB Output is correct
34 Correct 88 ms 10332 KB Output is correct
35 Correct 84 ms 11968 KB Output is correct
36 Correct 88 ms 12884 KB Output is correct
37 Correct 88 ms 10840 KB Output is correct
38 Correct 84 ms 10832 KB Output is correct
39 Correct 84 ms 11712 KB Output is correct
40 Correct 85 ms 9920 KB Output is correct
41 Correct 82 ms 9924 KB Output is correct
42 Correct 89 ms 12856 KB Output is correct
43 Correct 94 ms 11744 KB Output is correct
44 Correct 79 ms 9740 KB Output is correct
45 Correct 86 ms 12624 KB Output is correct
46 Correct 80 ms 9624 KB Output is correct
47 Correct 73 ms 9408 KB Output is correct
48 Correct 84 ms 12224 KB Output is correct
49 Correct 91 ms 13676 KB Output is correct
50 Correct 85 ms 9920 KB Output is correct
51 Correct 85 ms 9920 KB Output is correct
52 Correct 90 ms 12736 KB Output is correct
53 Correct 86 ms 10064 KB Output is correct