Skip to content

Instantly share code, notes, and snippets.

@uwi
Created September 2, 2012 05:40
Show Gist options
  • Save uwi/3595131 to your computer and use it in GitHub Desktop.
Save uwi/3595131 to your computer and use it in GitHub Desktop.
SRM554 本番メモ
AA
AA
AA *4
AB
AA *4
BB
AB
BA
AA *4*2?
BC
AB *4
CA
AB
CD
1+4+2+1+4+2+1
最小値はすぐ求まる
4までのときに他の並びで最小が実現できるかどうか
4 2 3 7
20
5 2 3 3 4 5
2 3 2 3
14?
Rx+Bx=Rs+Bs
Rx+B(x+1)
R(x+1)+Bx
Rs+Bs=Rx+B(x+1)
R(s-x)=B(x+1-s)
s-x=bk
x+1-s=rk
// Set<Long> set = new HashSet<Long>();
// for(int i = 1;i <= redCount && i <= blueCount;i++){
// set.add((long)redHeight*i+(long)blueHeight*i);
// }
// for(int i = 0;i <= redCount && i+1 <= blueCount;i++){
// set.add((long)redHeight*i+(long)blueHeight*(i+1));
// }
// for(int i = 0;i+1 <= redCount && i <= blueCount;i++){
// set.add((long)redHeight*(i+1)+(long)blueHeight*i);
// }
// return set.size();
R(s+1)+Bs=Rx+B(x+1)
R(s+1-x)=B(x+1-s)
s-x=bk-1=1-rk
s-x=bk=1-rk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment