着る毛布が届いた。Good bye 2013

今日は起きたら腰を痛めました。歳かな・・・。
そして、お昼ごろに着る毛布が届きました。来年かなーと思ってましたが。
しかし、今日は18度近くあり、普通に暖かめでした。

夜はピザを注文しようという話になり、ドミノ・ピザで。
1回目クイズに失敗したので、2回目やった結果こうなりました。

着る毛布が届いた。Good bye 2013_f0019846_4512395.jpg


お・・・おう。

着る毛布が届いた。Good bye 2013_f0019846_4513733.jpg


着る毛布が届いた。Good bye 2013_f0019846_451515.jpg


着る毛布が届いた。Good bye 2013_f0019846_452060.jpg


着る毛布が届いた。Good bye 2013_f0019846_452773.jpg


その後はゲーセンへ。

着る毛布が届いた。Good bye 2013_f0019846_4522514.jpg

灼熱91.3%

着る毛布が届いた。Good bye 2013_f0019846_4524355.jpg

Chaplet84.1%

着る毛布が届いた。Good bye 2013_f0019846_4531175.jpg

等速サイケデリック
着る毛布が届いた。Good bye 2013_f0019846_453293.jpg


着る毛布が届いた。Good bye 2013_f0019846_453447.jpg

DDRとかいう神ゲー。
2曲目にも選択して落ちましたけどね…。

着る毛布が届いた。Good bye 2013_f0019846_4542730.jpg

クッキーファンタジーフルコン。

着る毛布が届いた。Good bye 2013_f0019846_4544690.jpg

トリックポップフルコン

着る毛布が届いた。Good bye 2013_f0019846_455926.jpg

モフポップ銅★

着る毛布が届いた。Good bye 2013_f0019846_4553282.jpg

天空ワルツフルコン

着る毛布が届いた。Good bye 2013_f0019846_4555046.jpg

カプサイシン・・・。

夜はCodeforces Good Bye 2013に参加。

A問題。
最初にn本のろうそくがあり、この人はm本のろうそくのカスで1本ろうそくが作れる。
1本1時間もつとしたら、何時間分もたせられるか。
あまりの計算をちゃんとやりましょうというだけ。


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main2 {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] st = br.readLine().split(" ");
int a = Integer.parseInt(st[0]);
int b = Integer.parseInt(st[1]);
int time = 0;
int kasu = 0;
while(a != 0){
time += a;
kasu += a;
a = kasu / b;
kasu %= b;
}
System.out.println(time);
}
}


B問題。ロボットが左端にいて、バッグの中に金貨をつめていく。
いくつ必要かが配列で与えられていて、このロボットは左に移動するか右に移動するか、
コインを置くかの動作ができる。
しかし、このロボットは連続してコインを置く動作が取れない。
必要な動作を出力せよという問題。
二回連続じゃなきゃいいので、左なり右なり移動して戻った後に置けば良い。


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main2 {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String st = br.readLine();
int n = Integer.parseInt(st);
String[] str = br.readLine().split(" ");
int[] a = new int[n];
for(int i = 0 ; i < n ; i++){
a[i] = Integer.parseInt(str[i]);
}
int[] c = new int[n];
StringBuilder sb = new StringBuilder();
int rbindex = 0;
char ba = '-';
int nowindex = 0;
while(nowindex != n){
if(nowindex == rbindex){
if(c[rbindex] < a[rbindex]){
if(ba != 'P'){
sb.append("P");
c[rbindex]++;
ba = 'P';
}else{
if(rbindex + 1 == n){
sb.append("L");
rbindex--;
ba = 'L';
}else{
sb.append("R");
rbindex++;
ba = 'R';
}
}
}else{
if(nowindex != n-1){
sb.append("R");
ba = 'R';
nowindex++;
rbindex++;
}else{
nowindex++;
}
}
}else{
if(nowindex < rbindex){
sb.append("L");
rbindex--;
ba = 'L';
}else{
sb.append("R");
rbindex++;
ba = 'R';
}
}
}
System.out.println(sb.toString());
}
}


C問題は、欲しいと思ってるレートの配列が与えられていて、
運営側はそれを与えようと思っている。
しかし、各レートは独立でなければいけないが、なるべくあんまり多くのレートを与えたくない。
最小となるように与えた時のレートを出力せよ。答えが複数あればどれでもよい。

これは、レートと番号のペアを作ってソートして、
今まででかぶっている最低レートを更新させつつ、
そのレート以下になっていないかを見る。そのレート以下であれば、
そのレート+1を与えて、最低レートをそれに更新する。
かぶってなければ、最低レートを今の配列に更新する。

これをまた新たな配列にレートとして代入し、最後にその配列を出力する。
処理時間はわりとぎりぎり。

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;

public class Main2 {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String st = br.readLine();
int n = Integer.parseInt(st);
String[] str = br.readLine().split(" ");
int[] a = new int[n];
MyPair[] mp = new MyPair[n];
int[] lastnum = new int[n];
for(int i = 0 ; i < n ; i++){
a[i] = Integer.parseInt(str[i]);
mp[i] = new MyPair();
mp[i].setFirst(a[i]);
mp[i].setSecond(i);
}
Arrays.sort(mp);
int bfrate = -1;
for(int i = 0 ; i < mp.length ; i++){
if((Integer)mp[i].getFirst() <= bfrate){
mp[i].setFirst((Integer)mp[i].getFirst()+(bfrate-(Integer)mp[i].getFirst()+1));
}
bfrate = (Integer)mp[i].getFirst();
lastnum[(Integer)mp[i].getSecond()] = (Integer)mp[i].getFirst();
}

for(int i = 0 ; i < n ; i++){
if(i != n-1){
System.out.print(lastnum[i]+" ");
}else{
System.out.println(lastnum[i]);
}
}
}
}

class MyPair implements Cloneable,Comparable>, Serializable {
private static final long serialVersionUID = -553348920790587668L;
@Override
public MyPair clone() {
try {
return (MyPair) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e);
}
}
public MyPair(){//S first, T second) {
//this.first = first;
//this.second = second;
//return;
}
private S first;
private T second;
@SuppressWarnings("unchecked")
public MyPair(MyPair p) {
first = (S) p.getFirst();
second = (T) p.getSecond();
}
public S getFirst() {
return first;
}
public void setFirst(S first) {
this.first = first;
}
public T getSecond() {
return second;
}
public void setSecond(T second) {
this.second = second;
}
@Override
public boolean equals(Object obj) {
if (obj == this) { return true; }
if (!(obj instanceof MyPair)) { return false; }
MyPair pair = (MyPair) obj;
if (first == null) {
if (second == null) {
if (pair.first == null && pair.second == null) { return true; }
return false;
}
if (pair.first == null) { return second.equals(pair.second); }
return false;
}
if (second == null) {
if (first != null) {
if (pair.second == null) { return first.equals(pair.first); }
return false;
}
}
return first.equals(pair.first) && second.equals(pair.second);
}
/**
* hashcode
*/
@Override
public int hashCode() {
int result = 17;
result *= 31;
if (first != null) {
result += first.hashCode();
}
result *= 31;
if (second != null) {
result += second.hashCode();
}
return result;
}
@Override
public String toString() {
return "[" + (first != null ? first : "null") + ", " + (second != null ? second : "null") + "]";
}
@SuppressWarnings("unchecked")
public int compareTo(MyPair o) {// Comparable>
Comparable f = null;
Comparable s = null;
try {
f = (Comparable) first;
s = (Comparable) second;
} catch (ClassCastException e) {
throw new IllegalStateException(e);
}
if (f == null || s == null || o == null) throw new NullPointerException();
int c = f.compareTo(o.first);
if (c != 0) {return c; }
return s.compareTo(o.second);
}
}


D問題は、アルファベットの文字列s1,s2をつくり、
s3はs1+s2、s4はs2+s3というふうに作る。
ACの数が、s_kのとき丁度x個となるようなs1,s2を構成せよ。
なければHappy new year!を出力せよ という問題。
単なるフィボナッチと思いきや、端でACが作れる場合を考えなきゃいけないので、
かなり闇な問題です。無理でした。

くぅ~お疲れ様!これにて2013年Codeforces終了です!

  by ddrer-yossi | 2013-12-30 23:40 | codeforces

<< おみそかー なんともいえない一日になってし... >>

SEM SKIN - DESIGN by SEM EXE