結果

問題 No.929 よくあるボールを移動するやつ
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2019-11-22 22:08:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,837 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 198,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 11:35:19
合計ジャッジ時間 3,081 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	ll ans = 0;
	queue<int> empty;
	queue<int> rest;

	rep(i, 0, N) {
		int b; cin >> b;

		if (b == 0) {
			if (!rest.empty()) {
				int t = rest.front(); rest.pop();
				ans += i - t;
			}
			else empty.push(i);
		}
		else {
			while (1 < b and !empty.empty()) {
				int t = empty.front(); empty.pop();
				ans += i - t;
			}
			rep(j, 1, b) rest.push(i);
		}
	}

	cout << ans << endl;
}





0