Submission #566993

# Submission time Handle Problem Language Result Execution time Memory
566993 2022-05-23T07:07:59 Z almothana05 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
240 ms 9328 KB
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 100000000000000000
using namespace std;
vector<int>num;
vector<pair<int , int> >cmp , erg;
int suf[300001];
int main(){
   // ios_base::sync_with_stdio(false);
   // cin.tie(NULL);
   int menge,  numm , nummer;
   cin >> menge;
   for(int i = 0 ; i < menge + 1; i++){
      cin >> numm;
      cmp.push_back({numm , i});
   }
   for(int i = 0 ; i < menge ; i++){
      cin >> numm;
      num.push_back(numm);
   }
   sort(num.begin() , num.end());
   sort(cmp.begin() , cmp.end());
   for(int i = menge - 1 ; i >= 0 ; i--){
      // cout << cmp[i + 1] << ' ' << num[i] << "\n";
      suf[i] = max(suf[i + 1] , max(0 , cmp[i + 1].first - num[i]));
   }
   // return 0;
   int pref = 0;
   for(int i = 0 ; i < menge + 1; i++){
      if(i == 0){
          erg.push_back({cmp[i].second ,  max(suf[i] , pref)});
         continue;
      }
      pref = max(pref , max(0 , cmp[i - 1].first - num[i - 1]));
      erg.push_back({cmp[i].second , max(suf[i] , pref)});
      // cout << 
   }
   sort(erg.begin() , erg.end());
   for(int i = 0 ; i < erg.size() ; i++){
      cout << erg[i].second << " ";
   }
   cout << "\n";
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |    for(int i = 0 ; i < erg.size() ; i++){
      |                    ~~^~~~~~~~~~~~
ho_t1.cpp:11:23: warning: unused variable 'nummer' [-Wunused-variable]
   11 |    int menge,  numm , nummer;
      |                       ^~~~~~
# Verdict Execution time Memory 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 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory 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 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 218 ms 8344 KB Output is correct
34 Correct 235 ms 8960 KB Output is correct
35 Correct 214 ms 8584 KB Output is correct
36 Correct 227 ms 9016 KB Output is correct
37 Correct 225 ms 9328 KB Output is correct
38 Correct 228 ms 9128 KB Output is correct
39 Correct 215 ms 8288 KB Output is correct
40 Correct 224 ms 8288 KB Output is correct
41 Correct 217 ms 8428 KB Output is correct
42 Correct 221 ms 8256 KB Output is correct
43 Correct 211 ms 8384 KB Output is correct
44 Correct 240 ms 7916 KB Output is correct
45 Correct 209 ms 8020 KB Output is correct
46 Correct 227 ms 7944 KB Output is correct
47 Correct 203 ms 7820 KB Output is correct
48 Correct 217 ms 7804 KB Output is correct
49 Correct 228 ms 8420 KB Output is correct
50 Correct 232 ms 8412 KB Output is correct
51 Correct 226 ms 8408 KB Output is correct
52 Correct 223 ms 8396 KB Output is correct
53 Correct 233 ms 8368 KB Output is correct