結果
問題 |
No.3015 右に寄せろ!
|
ユーザー |
|
提出日時 | 2025-01-25 14:23:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 943 bytes |
コンパイル時間 | 4,446 ms |
コンパイル使用メモリ | 250,008 KB |
実行使用メモリ | 7,180 KB |
最終ジャッジ日時 | 2025-01-25 23:17:46 |
合計ジャッジ時間 | 6,036 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 WA * 24 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } int main() { string S; cin >> S; reverse(S.begin(),S.end()); long long movedNum = 0; long long wall = 0; long long state_one = 0; long long res = 0; rep(i,S.size()){ if(state_one == 0){ if(S[i] == '1'){ state_one = 1; } }else{ state_one = 0; if(S[i] == '0'){ wall++; movedNum = 0; }else{ res += i-1-wall-2*movedNum; movedNum++; } } } cout << res << endl; }