Submission #00022
ソースコード
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 | #include <bits/stdc++.h> using namespace std; #define int long long const int N = 200000; main() { int n; vector< int > d; map< int , int > min_idx; cin >> n; d.push_back(0); for ( int i = 0; i < n; ++i) { int di; cin >> di; d.push_back(di); } int sum = 0; int max_len = 0; for ( int i = 0; i < n + 1; ++i) { sum += d[i]; if (min_idx.count(sum) == 0) { min_idx[sum] = i; } else { max_len = max(max_len, i - min_idx[sum]); } } cout << max_len << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0005 - 完全平等二国間貿易 |
ユーザー名 | 七代目清水天三郎丸 |
投稿日時 | 2017-10-24 18:08:36 |
言語 | C++11 |
状態 | Accepted |
得点 | 8 |
ソースコード長 | 618 Byte |
最大実行時間 | 113 ms |
最大メモリ使用量 | 14520 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 8 / 8 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 18 ms | 480 KB |
1
|
in02.txt | AC | 22 ms | 452 KB |
1
|
in03.txt | AC | 19 ms | 428 KB |
1
|
in04.txt | AC | 12 ms | 400 KB |
1
|
in05.txt | AC | 19 ms | 500 KB |
1
|
in06.txt | AC | 17 ms | 476 KB |
1
|
in07.txt | AC | 15 ms | 448 KB |
1
|
in08.txt | AC | 22 ms | 544 KB |
1
|
in09.txt | AC | 23 ms | 504 KB |
1
|
in10.txt | AC | 15 ms | 560 KB |
1
|
in11.txt | AC | 18 ms | 472 KB |
1
|
in12.txt | AC | 19 ms | 568 KB |
1
|
in13.txt | AC | 19 ms | 476 KB |
1
|
in14.txt | AC | 22 ms | 580 KB |
1
|
in15.txt | AC | 22 ms | 552 KB |
1
|
in16.txt | AC | 16 ms | 1040 KB |
1
|
in17.txt | AC | 24 ms | 1684 KB |
1
|
in18.txt | AC | 29 ms | 2548 KB |
1
|
in19.txt | AC | 28 ms | 3308 KB |
1
|
in20.txt | AC | 46 ms | 2908 KB |
1
|
in21.txt | AC | 78 ms | 4244 KB |
1
|
in22.txt | AC | 64 ms | 5712 KB |
1
|
in23.txt | AC | 113 ms | 14520 KB |
1
|
in24.txt | AC | 43 ms | 2848 KB |
1
|
in25.txt | AC | 47 ms | 2780 KB |
1
|