QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#223521#1975. Vaccination Against CoronaRabeya#AC ✓16ms4732kbC++141.3kb2023-10-22 12:13:572023-10-22 12:13:57

Judging History

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

  • [2023-10-22 12:13:57]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:4732kb
  • [2023-10-22 12:13:57]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef unordered_map<int,int> umap;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define popcount __builtin_popcount
#define case cout<<"Case "<<__testcase-testcase<<": ";
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    int __testcase=testcase;
    while(testcase--){
        int n,m,i,j,k;
        cin>>n;
        int L; cin>>L;
        vii a(n); for(auto &i: a) cin>>i;
        sort(a.begin(), a.end());
        int dp[n+5][2];
        vii d(n);
        for(i=0;i<n;i++){
            j=(int)(lower_bound(a.begin(),a.end(),a[i]+L)-a.begin());
            d[i]=j;
        }

        dp[n][0]=dp[n][1]=0;
        dp[n-1][0]=0;
        dp[n-1][1]=1;

        for(i=n-2;i>=0;i--){
            dp[i][1]=min(dp[i+1][0], dp[i+1][1])+1;
            j=d[i];
            dp[i][0]=min(dp[j][0], dp[j][1])+(j-i-1);
            //cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
        }
        cout<<min(dp[0][0], dp[0][1])<<endl;
    }
}




详细

Test #1:

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

input:

5 2
-1 0 1 2 3

output:

2

result:

ok single line: '2'

Test #2:

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

input:

5 4
1 2 4 6 8

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 16ms
memory: 4636kb

input:

100000 1000
14494 99541 -37248 68011 15893 8200 51083 -30386 -62072 38920 -19011 46862 53103 77282 -10883 49995 -39899 -56038 46107 86019 70988 -89340 70980 5753 85602 1832 25094 -51345 -90418 62761 47041 -40479 -61175 41899 59937 5692 44937 -36366 -35853 -96232 -97144 18771 -92013 52943 80881 -7570...

output:

99799

result:

ok single line: '99799'

Test #4:

score: 0
Accepted
time: 10ms
memory: 4732kb

input:

100000 100000
97255 90951 82735 82647 66791 -74081 52 -9438 -92125 -97520 -28917 97455 14438 -69631 91245 -97516 73447 -16540 -78511 70588 -85763 2014 -27880 10359 -4118 -1549 4483 74326 -93882 94594 -8755 -12069 68335 -79894 -17747 9735 98003 -26983 79278 -4069 7167 87330 -1890 -10645 99 -83117 158...

output:

99997

result:

ok single line: '99997'

Test #5:

score: 0
Accepted
time: 14ms
memory: 4652kb

input:

100000 100000
-79883 2384 11852 25324 284 -48203 -64156 20723 95500 -1087 -8032 -11905 22072 -83603 -26472 -4648 -69271 -59414 -91752 5426 -16638 -47474 -8024 -22184 -33641 8141 -51414 -19894 5413 -26039 50238 -73932 96304 25772 -28904 49993 -84857 -98919 -79532 35728 -2763 -36623 -59680 20869 -4616...

output:

99998

result:

ok single line: '99998'

Test #6:

score: 0
Accepted
time: 15ms
memory: 4640kb

input:

100000 345
-69551 -35230 6648 86781 -75309 -42150 23730 23762 96149 -26942 35139 -85503 -76633 -83577 -61218 47403 26178 24484 -55949 99163 196 50262 -3214 -30144 77919 -67278 23050 49924 -40454 -1822 68359 71413 -40162 -42464 -69526 -21107 97199 -72485 16005 -1951 9322 -53935 -29868 -84182 17157 14...

output:

99431

result:

ok single line: '99431'

Test #7:

score: 0
Accepted
time: 16ms
memory: 4728kb

input:

100000 2
47253 -74158 -58884 43480 56941 -89704 50996 -92413 49075 57033 58204 48621 93543 2024 52027 75428 61337 49639 85815 54152 80711 70713 -69823 -76049 62748 85000 82239 48572 -9992 90692 62097 80155 96042 60421 95154 81426 72756 54700 41730 -6745 90868 56390 75399 77748 -81573 -67217 59042 -4...

output:

38759

result:

ok single line: '38759'

Test #8:

score: 0
Accepted
time: 16ms
memory: 4596kb

input:

100000 1
66421 1939 9490 13758 35877 37113 10879 -12316 50188 -34592 4416 -1786 93351 86072 -1174 95789 4296 -1983 45486 43671 11105 55381 15206 52887 -27730 59656 53911 39338 33505 -3032 22757 35703 -5626 -142 13137 5204 11583 14883 7447 77952 -29467 -18556 40807 38565 90786 58202 81875 -22484 8756...

output:

0

result:

ok single line: '0'

Test #9:

score: 0
Accepted
time: 12ms
memory: 4656kb

input:

100000 1
89477 56854 83732 20348 62040 7846 96340 1188 85728 26685 92879 60988 77931 58516 88640 83112 62458 9157 47363 9582 96923 52594 35182 45137 89451 33437 26595 26240 46042 57940 54622 27941 25959 90948 97046 38908 85090 77660 75983 54959 54732 87208 40935 14899 14242 5726 11125 97492 15790 23...

output:

0

result:

ok single line: '0'

Test #10:

score: 0
Accepted
time: 16ms
memory: 4716kb

input:

100000 2
-58808 -44668 -63126 18458 -35265 30326 -20233 6810 -33290 -30756 -47672 -60481 33209 49030 46780 -30777 -98338 -96184 -87448 30507 -1629 -42669 -3646 15981 -78124 44786 -86736 -18532 -31499 -25774 -80272 -71937 9086 -18338 -51753 -36647 -64912 -65257 39043 25119 -58690 -53249 29744 22281 4...

output:

42325

result:

ok single line: '42325'

Test #11:

score: 0
Accepted
time: 16ms
memory: 4636kb

input:

100000 123
84604 -1231 99027 -47230 -25807 -29020 -24450 62093 -28552 -32700 -5389 -27321 78978 72752 -11693 66207 93789 -26294 50701 55912 77655 84182 81865 -43919 79874 85205 -61756 66360 85008 56455 -26243 -42242 -43659 -51404 -47798 -40239 80306 -31209 -12098 83764 -24246 -25856 -57172 68010 -61...

output:

99012

result:

ok single line: '99012'

Test #12:

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

input:

2 100000
48454 48459

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 2ms
memory: 3800kb

input:

10000 200
30580 38209 29211 76181 69793 74410 14017 15383 18799 44806 99591 20400 77609 62790 6991 39389 60380 54382 71981 36820 45009 63796 73009 16418 63993 23586 59226 55786 39587 95199 35201 63608 16392 93597 7397 23793 34391 58811 71403 90382 57195 71002 80582 23381 60200 68007 24209 90610 9340...

output:

9500

result:

ok single line: '9500'

Test #14:

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

input:

1 100000
-62021

output:

0

result:

ok single line: '0'

Test #15:

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

input:

1 1
8983

output:

0

result:

ok single line: '0'