結果
| 問題 | No.3015 右に寄せろ! |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-01-28 16:00:01 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 667 bytes |
| 記録 | |
| コンパイル時間 | 419 ms |
| コンパイル使用メモリ | 52,864 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-25 17:11:05 |
| 合計ジャッジ時間 | 1,808 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3015.cc: No.3015 蜿ウ縺ォ蟇・○繧・ - yukicoder
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 2000000;
/* typedef */
using ll = long long;
/* global variables */
char s[MAX_N + 4];
/* subroutines */
/* main */
int main() {
scanf("%s", s);
int n = strlen(s);
ll sum = 0;
for (int i = 0, x = 0; i < n;) {
int l1 = 0, l0 = 0;
while (i < n && s[i] == '1') i++, l1++;
while (i < n && s[i] == '0') i++, l0++;
if (l0 > 0 && l1 > 0) {
x += l1 / 2;
sum += (ll)x * l0;
}
}
printf("%lld\n", sum);
return 0;
}
tnakao0123