QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#537617 | #4990. Coffee Cup Combo | xlwang | AC ✓ | 1ms | 3980kb | C++14 | 1.4kb | 2024-08-30 16:42:02 | 2024-08-30 16:42:02 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
#define pii pair<int,int>
#define mk make_pair
using namespace std;
inline int read(){
int x=0;
bool f=0;
char c=getchar();
while(!isdigit(c)) f|=(c=='-'),c=getchar();
while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
//inline void init(){
// int t=read();
// while(t--) work();
//}
const int Maxn=1e5+10;
char c[Maxn];
int n;
int ans,now;
inline void init(){
n=read();scanf("%s",c+1);
}
inline void work(){
fr(i,1,n){
if(c[i]=='1'){++ans;now=2;continue;}
if(now) --now,++ans;
}writeln(ans);
}
signed main(){
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
init();work();
// printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
10 0100010100
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
10 1100000000
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
1 0
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
10 1011111100
output:
10
result:
ok single line: '10'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
10 0000000110
output:
3
result:
ok single line: '3'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
10 0011000000
output:
4
result:
ok single line: '4'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
100000 00000101010001101100000001000000001101011000101111011111001000101100011101001010010110100000111100010011000110001111111100110111101010110011000000001110010000111111110111101000100111000001101101000100101000011101100010010001010100000011101100101001100111011111010100101000011100001011111001011...
output:
87328
result:
ok single line: '87328'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
100000 10000110000100111011000000101101000110011100011000101001110011000101100010011000010101000101011001000110101010111110000001101011111100011111111101111101011000010011111101101011111101101100011001101000100011111011111010100100110011010111001001001101011101110100100100011010100010111010001001100...
output:
87468
result:
ok single line: '87468'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
100000 00010000011000101101100100010011010000010010001000101000100001010000100011111001001101010000110100000000000000101100000000101001001100001111010000011000100101010110110011001011100001010100101100010000101001001001000010010001111001100100000010001000000010000000000111100001001000000000000000000...
output:
70493
result:
ok single line: '70493'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
100000 10000100010000010000011010000000001010000000011000000101000010001000000000000000000000000010000000000101000101100000001000000010000100100011010010000011101000100001100010000000000000000000010100100010000001010100100000100100111001000010010100001000101101000000110000000111110010000000000100000...
output:
57542
result:
ok single line: '57542'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3964kb
input:
100000 00001000000000000000010010000000000000000000000000110000100110000000100000001001011100000010100001001010001010000010000110000000010010000000001010000000010000000010000000010000000100001000010000100001001000100010000000001000011000011000101000001000000101000010001101010100100000001000001101001...
output:
49382
result:
ok single line: '49382'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
100000 01000001100001111000000100000000000011010000000010100001001010000100100000000000000001100000010010000100000001000000100100000110100000000000000000000000010010000010010000001000100010010100010000000000000000100000010000000000000010010010010000000000000000000000100101010111000000000001000000100...
output:
42426
result:
ok single line: '42426'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
100000 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
100000
result:
ok single line: '100000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
100000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
0
result:
ok single line: '0'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
100000 01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
99999
result:
ok single line: '99999'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
100000 00100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100...
output:
99998
result:
ok single line: '99998'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
100000 00010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010...
output:
74998
result:
ok single line: '74998'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
100000 10100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100100010100...
output:
88889
result:
ok single line: '88889'