Submission #00046
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include<bits/stdc++.h> using namespace std; int main(){ int W,H,N; cin >> W >> H >> N; int nowx,nowy; cin >> nowx >> nowy; int ans = 0; for ( int i=1;i<N;i++){ int nextx,nexty; cin >> nextx >> nexty; int crossx = nextx-nowx; int crossy = nexty-nowy; if ((crossx < 0 && crossy < 0) || (crossx > 0 && crossy > 0)){ crossx = abs (crossx); crossy = abs (crossy); int cost = min(crossx,crossy); crossx -= cost; crossy -= cost; ans += cost + crossx + crossy; nowx = nextx; nowy = nexty; } else { crossx = abs (crossx); crossy = abs (crossy); ans += crossx + crossy; nowx = nextx; nowy = nexty; } } cout << ans << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0003 - 超都観光 (Super Metropolis) |
ユーザー名 | ei1428 |
投稿日時 | 2016-12-02 15:57:45 |
言語 | C++11 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 766 Byte |
最大実行時間 | 22 ms |
最大メモリ使用量 | 576 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | in1 | 20 / 20 | *1.txt |
2 | in2 | 20 / 20 | *[12].txt |
3 | in3 | 20 / 20 | *[1-3].txt |
4 | in4 | 20 / 20 | *[1-4].txt |
5 | in5 | 20 / 20 | *[1-5].txt |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | ||||
---|---|---|---|---|---|---|---|---|
2014-yo-t3-in1.txt | AC | 17 ms | 480 KB |
1
|
2
|
3
|
4
|
5
|
2014-yo-t3-in2.txt | AC | 22 ms | 468 KB |
2
|
3
|
4
|
5
|
|
2014-yo-t3-in3.txt | AC | 21 ms | 576 KB |
3
|
4
|
5
|
||
2014-yo-t3-in4.txt | AC | 21 ms | 436 KB |
4
|
5
|
|||
2014-yo-t3-in5.txt | AC | 16 ms | 548 KB |
5
|