結果
問題 |
No.3015 右に寄せろ!
|
ユーザー |
|
提出日時 | 2025-01-25 14:18:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 953 bytes |
コンパイル時間 | 3,927 ms |
コンパイル使用メモリ | 251,212 KB |
実行使用メモリ | 7,184 KB |
最終ジャッジ日時 | 2025-01-25 23:15:41 |
合計ジャッジ時間 | 5,665 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 WA * 28 |
ソースコード
#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 = -1; 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 = i - 1; movedNum = 0; }else{ res += i-wall-2-2*movedNum; movedNum++; } } } cout << res << endl; }