結果
問題 | No.1007 コイン集め |
ユーザー | outline |
提出日時 | 2020-03-06 22:25:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 14 ms / 1,500 ms |
コード長 | 1,713 bytes |
コンパイル時間 | 953 ms |
コンパイル使用メモリ | 109,848 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-04 11:11:49 |
合計ジャッジ時間 | 2,353 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,384 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 14 ms
4,380 KB |
testcase_13 | AC | 13 ms
4,376 KB |
testcase_14 | AC | 14 ms
4,376 KB |
testcase_15 | AC | 8 ms
4,376 KB |
testcase_16 | AC | 8 ms
4,380 KB |
testcase_17 | AC | 8 ms
4,380 KB |
testcase_18 | AC | 14 ms
4,376 KB |
testcase_19 | AC | 14 ms
4,380 KB |
testcase_20 | AC | 14 ms
4,380 KB |
testcase_21 | AC | 14 ms
4,380 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <string> #include <map> #include <set> #include <tuple> #include <deque> #include <numeric> #include <bitset> #include <iomanip> #include <cassert> #include <chrono> #include <random> #include <limits> #include <iterator> #include <functional> #include <sstream> #include <complex> using namespace std; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) typedef long long ll; typedef pair<int, int> P; typedef pair<int, double> Pid; typedef pair<double, int> Pdi; typedef pair<ll, int> Pl; typedef pair<int, pair<int, int>> PP; constexpr double PI = 3.1415926535897932; // acos(-1) constexpr double EPS = 1e-10; constexpr int INF = 1001001001; constexpr int mod = 1e+9 + 7; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; --k; vector<ll> a(n); for(int i = 0; i < n; ++i) cin >> a[i]; if(a[k] == 0){ cout << 0 << endl; return 0; } int pos = k; ll left = 0; while(pos > 0){ --pos; if(pos == 0){ left += a[0]; break; } if(a[pos] <= 1){ left += a[pos]; break; } left += a[pos]; } pos = k; ll right = 0; while(pos < n - 1){ ++pos; if(pos == n - 1){ right += a[n - 1]; break; } if(a[pos] <= 1){ right += a[pos]; break; } right += a[pos]; } if(a[k] == 1){ cout << max(left, right) + a[k] << endl; } else{ cout << left + right + a[k] << endl; } }