Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
[ABC] Create 024/c but has not been solved #15
Browse files Browse the repository at this point in the history
  • Loading branch information
himkt committed May 4, 2016
1 parent e7098db commit b3c2cf2
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
71 changes: 71 additions & 0 deletions atcoder/abc/024/c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n) FOR(i,0,n)
# include <iostream>
# include <algorithm>
# include <iterator>
# include <cstdlib>

using namespace std;

int main() {

int N, D, K;
cin >> N >> D >> K;
int L[D], R[D], S[K], T[K], step[K];

REP(i, D) {
cin >> L[i] >> R[i];
}

REP(i, K) {
cin >> S[i] >> T[i];
}

REP(i, D) {

// それぞれの民族について
REP(j, K) {

// 目的地にいない場合
if (S[j] != T[j]) {
// できるだけ近くに行く

// 移動しきれる
if (L[i] <= T[j] && T[j] <= R[i]) {
S[j] = T[j];

// 移動しきれない
} else {
step[j]++;

// L or R
if (abs(T[j] - L[i]) < abs(T[j] - R[i])){
S[j] = L[i];
} else {
S[j] = R[i];
}

}

}
}

// みんな移動終了していたら終わり
bool flag = true;
REP(i, D) {
if (S[i] != T[i]) {
flag = false;
break;
}
}

REP(i, D) {
cout << i << ' ' << S[i] << ' ' << T[i] << endl;
}

if (flag) {
cout << i+1 << endl;
return 0;
}
}
}
45 changes: 45 additions & 0 deletions atcoder/abc/024/c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

N, D, K = map(int, input().split())
L = list()
R = list()
S = list()
T = list()
ans = list(0 for _ in range(K))

for d in range(D):
l, r = map(int, input().split())
L.append(l)
R.append(r)

for k in range(K):
s, t = map(int, input().split())
S.append(s)
T.append(t)


# for each stage
for d in range(D):

print(S)
print(T)


# for each people
for k in range(K):

if (S[k] == T[k]):
continue

if (L[d] <= T[k] and T[k] <= R[d]):
S[k] = T[k]
ans[k] += 1

elif (abs(T[k] - L[d]) < abs(T[k] - R[d])):
S[k] = L[d]
ans[k] += 1

elif (abs(T[k] - L[d]) > abs(T[k] - R[d])):
S[k] = R[d]
ans[k] += 1

print(ans)

0 comments on commit b3c2cf2

Please sign in to comment.