QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#424502#2960. Social DistancingTheSleepyDevil#AC ✓125ms3920kbC++202.9kb2024-05-29 11:30:372024-05-29 11:30:37

Judging History

你现在查看的是最新测评结果

  • [2024-05-29 11:30:37]
  • 评测
  • 测评结果:AC
  • 用时:125ms
  • 内存:3920kb
  • [2024-05-29 11:30:37]
  • 提交

answer

/*
     Hell, 'til I reach Hell, I ain't scared
     Mama checkin' in my bedroom, I ain't there
                                                */
    #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;

    #define Major  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    #define read(a,n) for(int i = 0 ; i<n ; i++) cin>>a[i];
    #define write(a) for(auto x : a) cout<<x<<" ";
    #define int long long
    #define pb push_back
    #define all(a)  a.begin(),a.end()
    #define el "\n"

    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

    const int inf=4e18;

    int dx[]={1,0,-1,0,1,1,-1,-1};
    int dy[]={0,1,0,-1,1,-1,1,-1};

    const int mod=1e9+7;
    const int MAX =1e6+7;

   // ---------------------------Function----------------------------------//

    void TestCake(){
       int all,n;
       cin>>all>>n;
       vector<int>arr(n);
       read(arr,n);
       map<int,int>mp;
       for(auto x : arr)mp[x]++;
       int ans=0;
        for(int j=1;j<=all;j++){
          map<int,int>tmp=mp;
          int cnt=0;
           for(int i=j;i<=all;i++){
              if(i!=1&&i!=all){
                  if(!tmp[i]&&!tmp[(i-1)]&&!tmp[i+1]){
                     cnt++;
                    tmp[i]=1;
                  }
              }
              else if(i==1){
                 if(!tmp[1]&&!tmp[all]&&!tmp[2]){
                    tmp[1]++;
                    cnt++;
                 }
              }
              else{
                 if(!tmp[all]&&!tmp[all-1]&&!tmp[1]){
                    cnt++;
                    tmp[all]=1;
                 }
              }
           }
           for(int i=1;i<j;i++){
                 if(i!=1&&i!=all){
                    if(!tmp[i]&&!tmp[(i-1)]&&!tmp[i+1]){
                         cnt++;
                        tmp[i]=1;
                      }
                  }
                  else if(i==1){
                     if(!tmp[1]&&!tmp[all]&&!tmp[2]){
                        tmp[1]++;
                        cnt++;
                     }
                  }
                  else{
                     if(!tmp[all]&&!tmp[all-1]&&!tmp[1]){
                        cnt++;
                     }
                  }
           }
           ans=max(ans,cnt);
        }
       cout<<ans;
    }
    //------------------------------Main---------------------------//
    signed main(){
        Major
        int T = 1;
//        cin >> T;
        while(T--){
            TestCake();
        //       cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
        }
        return 0;
    }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

9 2
2 6

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

10 3
1 4 7

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

6 2
2 5

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

100 5
7 14 47 78 99

output:

43

result:

ok single line: '43'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

6 1
3

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

3 1
1

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

4 2
1 3

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

4 2
2 4

output:

0

result:

ok single line: '0'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

5 2
1 3

output:

0

result:

ok single line: '0'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

5 2
2 4

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

5 2
3 5

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

5 2
1 4

output:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

5 2
2 5

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

7 1
1

output:

2

result:

ok single line: '2'

Test #15:

score: 0
Accepted
time: 87ms
memory: 3660kb

input:

1000 1
1

output:

499

result:

ok single line: '499'

Test #16:

score: 0
Accepted
time: 89ms
memory: 3704kb

input:

1000 1
2

output:

499

result:

ok single line: '499'

Test #17:

score: 0
Accepted
time: 85ms
memory: 3676kb

input:

1000 1
1000

output:

499

result:

ok single line: '499'

Test #18:

score: 0
Accepted
time: 91ms
memory: 3624kb

input:

1000 1
999

output:

499

result:

ok single line: '499'

Test #19:

score: 0
Accepted
time: 72ms
memory: 3652kb

input:

1000 500
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 17...

output:

0

result:

ok single line: '0'

Test #20:

score: 0
Accepted
time: 74ms
memory: 3680kb

input:

1000 500
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 ...

output:

0

result:

ok single line: '0'

Test #21:

score: 0
Accepted
time: 71ms
memory: 3904kb

input:

999 499
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173...

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 71ms
memory: 3644kb

input:

999 499
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 1...

output:

0

result:

ok single line: '0'

Test #23:

score: 0
Accepted
time: 72ms
memory: 3704kb

input:

999 498
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173...

output:

1

result:

ok single line: '1'

Test #24:

score: 0
Accepted
time: 90ms
memory: 3732kb

input:

999 333
2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 50 53 56 59 62 65 68 71 74 77 80 83 86 89 92 95 98 101 104 107 110 113 116 119 122 125 128 131 134 137 140 143 146 149 152 155 158 161 164 167 170 173 176 179 182 185 188 191 194 197 200 203 206 209 212 215 218 221 224 227 230 233 236 239 242 245 ...

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 108ms
memory: 3920kb

input:

1000 250
3 7 11 15 19 23 27 31 35 39 43 47 51 55 59 63 67 71 75 79 83 87 91 95 99 103 107 111 115 119 123 127 131 135 139 143 147 151 155 159 163 167 171 175 179 183 187 191 195 199 203 207 211 215 219 223 227 231 235 239 243 247 251 255 259 263 267 271 275 279 283 287 291 295 299 303 307 311 315 31...

output:

250

result:

ok single line: '250'

Test #26:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

100 3
9 12 24

output:

46

result:

ok single line: '46'

Test #27:

score: 0
Accepted
time: 1ms
memory: 3500kb

input:

100 10
19 21 27 33 57 71 74 80 86 99

output:

39

result:

ok single line: '39'

Test #28:

score: 0
Accepted
time: 100ms
memory: 3684kb

input:

1000 5
379 544 574 769 776

output:

493

result:

ok single line: '493'

Test #29:

score: 0
Accepted
time: 125ms
memory: 3616kb

input:

1000 100
9 32 34 49 66 73 75 96 99 102 108 110 112 115 118 120 128 134 149 161 168 192 194 219 230 246 250 276 293 304 306 330 333 343 358 369 375 381 404 418 421 428 434 454 457 462 465 497 499 502 514 516 518 532 536 539 549 552 556 562 570 581 584 590 618 653 663 666 668 709 712 726 730 749 757 7...

output:

377

result:

ok single line: '377'

Test #30:

score: 0
Accepted
time: 123ms
memory: 3624kb

input:

1000 200
3 14 18 20 26 31 37 41 47 51 55 59 63 67 73 75 80 85 88 91 94 98 105 110 114 116 123 129 131 134 143 147 150 157 161 163 167 173 176 178 187 190 192 194 200 210 217 220 228 232 238 241 248 250 252 267 272 277 281 285 292 296 302 310 315 319 323 331 337 341 345 350 354 358 361 368 374 378 38...

output:

256

result:

ok single line: '256'

Test #31:

score: 0
Accepted
time: 103ms
memory: 3920kb

input:

1000 333
2 6 10 13 15 17 20 22 25 27 29 33 35 38 42 45 47 49 51 55 58 60 62 65 67 69 73 75 80 82 86 93 95 97 102 106 108 111 113 116 121 124 126 135 138 144 146 151 154 157 161 166 168 171 173 175 178 181 183 186 188 190 192 195 199 201 205 208 212 214 220 222 225 227 229 231 233 235 238 240 242 245...

output:

104

result:

ok single line: '104'

Test #32:

score: 0
Accepted
time: 91ms
memory: 3892kb

input:

1000 400
2 4 6 9 11 14 16 18 20 22 25 30 33 36 39 42 45 47 49 51 54 56 59 61 63 65 68 70 72 75 78 81 85 87 89 91 93 95 98 101 103 105 108 110 112 114 117 119 122 125 127 130 135 137 140 142 145 147 150 152 154 157 161 163 165 167 169 171 173 176 178 180 183 186 188 191 193 196 198 202 204 207 210 21...

output:

27

result:

ok single line: '27'