QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#233290#2698. Flip FlowFyind#AC ✓1ms3864kbC++141.4kb2023-10-31 16:07:102023-10-31 16:07:11

Judging History

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

  • [2023-10-31 16:07:11]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3864kb
  • [2023-10-31 16:07:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define _ <<" "<<
#define sz(x) ((int)x.size())
typedef long long ll;
int n;
typedef pair<int,int> pii;

namespace IO {
#define gc getchar()
#define pc(x) putchar(x)
    template<typename T>inline void read(T &x) {
        x=0;
        int f=1;
        char ch=gc;
        while(ch>'9'||ch<'0') {
            if(ch=='-')f=-1;
            ch=gc;
        }
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;//如果读入就要取模,就加一句x=x%mod
        x*=f;
        return;
    }
    template<typename T>inline void write(T x=0) {
        T wr[51];
        wr[0]=0;
        if(x<0)pc('-'),x=-x;
        if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;
        while(wr[0])pc(48+wr[wr[0]--]);
        return;
    }
}
using IO::read;
using IO::write;


#define debug(x)  cout<<#x<<':'<<x<<endl;

const int maxn=1e5+100;
int c[maxn];
const int M=1<<25;


int main(){
   
    int t,s,n;
    read(t);
    read(s);
    read(n);

    vector<ll>a(n+1);
    ll up=0;ll down=s;
    a[n]=t;
    int last=0;
    for(int i=0;i<n+1;i++){
        
        cin>>a[i];

        ll delta=a[i]-last;

        ll imin=min(up,delta);
        up-=imin;down+=imin;
        swap(up,down);
        last=a[i];
       // debug(up);debug(down);
    }


    cout<<down<<endl;
    

    

    
}

详细

Test #1:

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

input:

100 80 1
50

output:

30

result:

ok single line: '30'

Test #2:

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

input:

100 30 1
50

output:

0

result:

ok single line: '0'

Test #3:

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

input:

100 50 2
30 79

output:

28

result:

ok single line: '28'

Test #4:

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

input:

100 50 2
30 80

output:

30

result:

ok single line: '30'

Test #5:

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

input:

100 50 2
30 81

output:

31

result:

ok single line: '31'

Test #6:

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

input:

10 7 2
4 9

output:

4

result:

ok single line: '4'

Test #7:

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

input:

2 1 1
1

output:

0

result:

ok single line: '0'

Test #8:

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

input:

2 1000000 1
1

output:

999999

result:

ok single line: '999999'

Test #9:

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

input:

10 1 9
1 2 3 4 5 6 7 8 9

output:

0

result:

ok single line: '0'

Test #10:

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

input:

11 1 10
1 2 3 4 5 6 7 8 9 10

output:

0

result:

ok single line: '0'

Test #11:

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

input:

1000000 1000000 1000
344 537 560 846 1947 2404 4212 6558 7411 8239 8807 10613 10967 11501 12280 13635 17353 17646 19480 20208 20940 21130 22176 22890 23738 25718 26413 26859 28252 29024 29808 31057 31339 34445 35596 37005 37050 37133 39154 39685 40345 41332 42262 43972 44905 46263 46428 47025 47742 ...

output:

41406

result:

ok single line: '41406'

Test #12:

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

input:

2000 333 3
1000 1250 1500

output:

0

result:

ok single line: '0'

Test #13:

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

input:

100 10 5
15 20 93 96 97

output:

5

result:

ok single line: '5'

Test #14:

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

input:

616658 68644 966
365 664 1505 2432 3458 3807 4532 4795 5425 5891 5949 7209 7416 7666 8836 8958 9037 9659 10899 11894 11972 12448 12867 12892 12942 13560 13677 15213 15858 16339 16717 17213 17511 17869 18089 19066 19524 19747 20537 21087 21365 21593 21701 22336 22555 22677 24240 25230 26585 29190 297...

output:

10727

result:

ok single line: '10727'

Test #15:

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

input:

264267 163935 485
32 116 650 830 886 1485 1498 1976 2435 3076 3167 3965 4054 4103 5572 6783 6806 7836 8673 8822 9205 9733 10487 11915 12103 12215 13140 13562 13754 14482 14643 15135 15481 15660 16638 16826 18518 18538 19466 19702 20130 20582 21467 21790 22051 23354 23858 24548 24662 25613 25670 2605...

output:

148158

result:

ok single line: '148158'

Test #16:

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

input:

290852 685196 940
168 657 676 826 894 955 1174 1523 1677 2140 2317 2992 3052 3740 4137 4926 4999 5010 5100 5541 5797 5847 6170 6911 7009 7102 7120 7358 7544 7752 7783 8767 9033 9067 9338 9852 9892 10178 10979 11488 11802 11827 11932 12228 13255 13644 13714 13916 14333 14640 14718 15152 15379 15519 1...

output:

11688

result:

ok single line: '11688'

Test #17:

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

input:

331962 696222 138
31 1877 3009 7552 9505 11088 11293 12557 17097 19693 24059 27288 27562 28711 29630 33002 34111 39445 42601 53983 54291 62804 63897 64228 65440 65462 66099 68468 72308 72430 73158 76084 77804 78346 78946 82518 84667 84879 88869 89535 99834 100516 101195 101333 106761 106838 107085 1...

output:

10175

result:

ok single line: '10175'

Test #18:

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

input:

490236 710967 510
55 218 459 572 3052 3930 4647 4995 5985 6986 10236 10756 11196 11319 13697 13960 14952 16550 18485 20446 20857 21087 22122 22986 24956 25454 27927 27988 30545 30589 31120 31570 31802 33173 33755 34308 34777 36463 38165 38603 38967 39125 41104 42218 42914 43811 46774 48559 49364 494...

output:

3345

result:

ok single line: '3345'

Test #19:

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

input:

887557 280821 184
10054 14407 15602 18476 20179 21802 28240 29993 34632 53225 53679 60018 60562 65878 75758 77968 82002 85631 88380 91371 94131 116192 124559 125848 141179 147583 161654 168831 170772 178438 186152 186734 191001 191384 196776 196909 203432 205581 209693 210738 215533 220170 220957 22...

output:

22405

result:

ok single line: '22405'

Test #20:

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

input:

931066 503685 810
222 936 1338 2217 2574 2695 2702 4306 7070 8178 9295 10334 14006 15568 16098 18157 19264 19623 21185 21468 22497 24922 25039 26677 29074 29248 34505 35713 37586 37762 38099 40047 40775 41287 41845 43451 43660 44067 47925 50405 51436 51477 53887 54378 56136 56592 59173 59272 59549 6...

output:

55443

result:

ok single line: '55443'

Test #21:

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

input:

367830 447254 734
2278 2475 2654 3942 4002 4003 4841 6140 6291 6643 7141 8928 9261 10897 11494 11598 11927 14174 15395 15921 16253 16791 17770 17787 17829 18155 18482 18616 19527 19677 21353 21678 22610 22686 23268 23360 24097 24816 24931 25338 25494 25555 25606 25912 25933 27109 27198 27545 27603 2...

output:

19750

result:

ok single line: '19750'

Test #22:

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

input:

4572 803351 812
6 9 11 20 24 25 33 35 47 60 61 64 66 79 83 85 92 94 95 96 102 106 135 139 143 147 150 152 154 157 159 173 186 188 201 206 210 215 221 225 232 238 239 246 252 254 256 262 263 269 279 283 288 289 295 296 307 316 323 325 331 337 343 355 356 360 371 376 379 380 388 391 392 393 413 422 42...

output:

14

result:

ok single line: '14'

Test #23:

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

input:

686456 305829 992
5 555 875 1485 1702 1771 1938 2099 3296 4688 5285 6743 7821 9404 11077 11143 13575 14287 15467 15607 15663 16346 16648 18197 19516 19702 20929 24002 24405 28461 29021 29103 29452 30368 33602 33636 35320 35416 37027 38150 38705 38823 38902 39357 40238 40300 40874 41096 41728 41764 4...

output:

15922

result:

ok single line: '15922'