Codeforces Global Round 3 A. Another One Bites The Dust
A. Another One Bites The Dust
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Let’s call a string good if and only if it consists of only two types of letters — ‘a(chǎn)’ and ‘b’ and every two consecutive letters are distinct. For example “baba” and “aba” are good strings and “abb” is a bad string.
You have a strings “a”, b strings “b” and c strings “ab”. You want to choose some subset of these strings and concatenate them in any arbitrarily order.
What is the length of the longest good string you can obtain this way?
Input
The first line contains three positive integers a, b, c (1≤a,b,c≤109) — the number of strings “a”, “b” and “ab” respectively.
Output
Print a single number — the maximum possible length of the good string you can obtain.
Examples
input
1 1 1
output
4
input
2 1 2
output
7
input
3 5 2
output
11
input
2 2 1
output
6
input
1000000000 1000000000 1000000000
output
4000000000
Note
In the first example the optimal string is “baba”.
In the second example the optimal string is “abababa”.
In the third example the optimal string is “bababababab”.
In the fourth example the optimal string is “ababab”.
Code
/*^....0^ .1 ^1^.. 011.^ 1.0^ 1 ^ ^0.11 ^ ^..^0. ^ 0^.0 1 .^.1 ^0 .........001^.1 1. .111100....01^00 11^ ^1. .1^1.^ ^0 0^.^ ^0..1.1 1..^1 .0 ^ ^00. ^^0.^^ 0 ^^110.^0 0 ^ ^^^10.01^^ 10 1 1 ^^^1110.101 10 1.1 ^^^1111110010 01 ^^ ^^^1111^1.^ ^^^10 10^ 0^ 1 ^^111^^^0.1^ 1....^11 0 ^^11^^^ 0.. ....1^ ^ ^1. 0^ ^11^^^ ^ 1 111^ ^ 0.10 00 11 ^^^^^ 1 0 1.0^ ^0 ^0 ^^^^ 0 0.0^ 1.0 .^ ^^^^ 1 1 .0^.^ ^^ 0^ ^1 ^^^^ 0. ^.11 ^ 11 1. ^^^ ^ ^ ..^^..^ ^1 ^.^ ^^^ .0 ^.00..^ ^0 01 ^^^ .. 0..^1 .. .1 ^.^ ^^^ 1 ^ ^0001^ 1. 00 0. ^^^ ^.0 ^.1. 0^. ^.^ ^.^ ^^^ ..0.01 .^^. .^ 1001 ^^ ^^^ . 1^. ^ ^. 11 0. 1 ^ ^^ 0.0 ^. 0 ^0 1 ^^^ 0.0.^ 1. 0^ 0 .1 ^^^ ...1 1. 00 . .1 ^^^ ..1 1. ^. 0 .^ ^^ ..0. 1. .^ . 0 ..1 1. 01 . . ^ 0^.^ 00 ^0 1. ^ 1 1.0 00 . ^^^^^^ ..^ 00 01 ..1. 00 10 1 ^^.1 00 ^. ^^^ .1.. 00 .1 1..01 ..1.1 00 1. ..^ 10^ 1^ 00 ^.1 0 1 1.1 00 00 ^ 1 ^. 00 ^.^ 10^ ^^1.1 00 00 10^..^ 1. ^. 1.0 1 ^. 00 00 .^^ ^. ^ 1 00 ^0000^ ^ 011 0 ^. 00.0^ ^00000 1.00.1 11. 1 0 1^^0.01 ^^^ 01.^ ^ 1 1^^ ^.^1 1 0... 1 ^1 1^ ^ .01 ^ 1.. 1.1 ^0.0^ 0 1..01^^100000..0^1 1 ^ 1 ^^1111^ ^^0 ^ ^ 1 1000^.1 ^.^ . 00.. 1.1 0. 01. . 1. .^1. 1 1. ^0^ . ^.1 00 01^.0 001. .^*/ // 2019_6_1 —— A. Another One Bites The Dust.cpp created by VB_KoKing on 2019-06-01:23. /* Procedural objectives:Variables required by the program:Procedural thinking:Functions required by the program:Determination algorithm:Determining data structure:*/ /* My dear Max said: "I like you, So the first bunch of sunshine I saw in the morning is you, The first gentle breeze that passed through my ear is you, The first star I see is also you. The world I see is all your shadow."FIGHTING FOR OUR FUTURE!!! */ #include <cstdio> #include <iostream> #include <algorithm>using namespace std;long long a,b,c,maxn;int main(){scanf("%lld %lld %lld",&a,&b,&c);if(a==b) maxn=2*(a+c);else maxn=2*(c+min(a,b))+1;cout<<maxn<<endl;return 0; } 與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的Codeforces Global Round 3 A. Another One Bites The Dust的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2019第十届蓝桥杯C/C++ A组省赛
- 下一篇: Google 都在用的 6 个休息小技巧