Submission #41976
ソースコード
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> using namespace std; #define rep(i,n) for(int i=0; i<(n); ++i) #define outl(x) cout<< (x) << '\n' using pii = pair< int , int >; using ll = long long ; template < class A, class B> inline bool chmax(A &a, B b){ return b>a ? a=b,1 : 0;} template < class A, class B> inline bool chmin(A &a, B b){ return b<a ? a=b,1 : 0;} static constexpr int INF = 0x3f3f3f3f; static constexpr int LIM = 100010; int main() { cin.tie(0), ios::sync_with_stdio( false ); int W, H, N; static int colMax[LIM], rowMax[LIM]; static int down[LIM], right[LIM]; cin >> W >> H >> N; rep(i, N) { int x, y; cin >> x >> y; chmax(colMax[x], y); chmax(rowMax[y], x); } int maxv; maxv = 0; for ( int x = W; x >= 1; --x) { chmax(maxv, colMax[x]); down[x-1] = maxv; } maxv = 0; for ( int y = H; y >= 1; --y) { chmax(maxv, rowMax[y]); right[y-1] = maxv; } int ans = INF; rep(x, W) chmin(ans, x + down[x]); rep(y, H) chmin(ans, y + right[y]); outl(ans); return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0962 - ダンジョン |
ユーザー名 | Arumakan_ei1727 |
投稿日時 | 2018-08-27 21:01:13 |
言語 | C++14 |
状態 | Accepted |
得点 | 11 |
ソースコード長 | 1208 Byte |
最大実行時間 | 41 ms |
最大メモリ使用量 | 2320 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 11 / 11 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1.txt | AC | 21 ms | 600 KB |
1
|
in2.txt | AC | 19 ms | 628 KB |
1
|
in3.txt | AC | 19 ms | 516 KB |
1
|
in4.txt | AC | 17 ms | 776 KB |
1
|
in5.txt | AC | 22 ms | 592 KB |
1
|
in6.txt | AC | 17 ms | 532 KB |
1
|
in7.txt | AC | 15 ms | 600 KB |
1
|
in8.txt | AC | 18 ms | 672 KB |
1
|
in9.txt | AC | 16 ms | 620 KB |
1
|
in10.txt | AC | 19 ms | 676 KB |
1
|
in11.txt | AC | 20 ms | 616 KB |
1
|
in12.txt | AC | 21 ms | 684 KB |
1
|
in13.txt | AC | 17 ms | 496 KB |
1
|
in14.txt | AC | 20 ms | 564 KB |
1
|
in15.txt | AC | 14 ms | 504 KB |
1
|
in16.txt | AC | 22 ms | 440 KB |
1
|
in17.txt | AC | 21 ms | 492 KB |
1
|
in18.txt | AC | 23 ms | 2068 KB |
1
|
in19.txt | AC | 29 ms | 2016 KB |
1
|
in20.txt | AC | 32 ms | 1720 KB |
1
|
in21.txt | AC | 27 ms | 1644 KB |
1
|
in22.txt | AC | 25 ms | 1828 KB |
1
|
in23.txt | AC | 34 ms | 1756 KB |
1
|
in24.txt | AC | 26 ms | 532 KB |
1
|
in25.txt | AC | 39 ms | 1764 KB |
1
|
in26.txt | AC | 41 ms | 1688 KB |
1
|
in27.txt | AC | 27 ms | 1984 KB |
1
|
in28.txt | AC | 22 ms | 2320 KB |
1
|
in29.txt | AC | 20 ms | 2248 KB |
1
|
in30.txt | AC | 33 ms | 2252 KB |
1
|