結果
| 問題 |
No.3210 Fixed Sign Sequense
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-25 21:38:44 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,201 bytes |
| コンパイル時間 | 11,246 ms |
| コンパイル使用メモリ | 398,204 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-07-25 21:39:00 |
| 合計ジャッジ時間 | 13,147 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 WA * 8 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:5:9 | 5 | let n = input.next::<usize>(); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
use library::utils::input::Input;
fn main() {
let mut input = Input::new();
let n = input.next::<usize>();
let s = input.next::<String>();
let mut ans = vec![0, 0];
for c in s.chars() {
if c=='-' {
ans[0] += 1;
} else if c=='0' {
ans[1] = ans[1].max(ans[0] + 1);
} else {
ans[1] += 1;
}
}
println!("{}", ans.iter().max().unwrap());
}
// ===== bundled library =====
pub mod library {
pub mod utils {
pub mod input {
use std::str::{from_utf8, FromStr};
pub struct Input {
buf: Vec<u8>,
pos: usize,
}
impl Input {
pub fn new() -> Self {
Self { buf: Vec::new(), pos: 0 }
}
pub fn next<T: FromStr>(&mut self) -> T {
while self.pos < self.buf.len()
&& self.buf[self.pos].is_ascii_whitespace()
{
self.pos += 1;
}
let start = self.pos;
while self.pos < self.buf.len()
&& !self.buf[self.pos].is_ascii_whitespace()
{
self.pos += 1;
}
if start == self.pos {
let mut input = String::new();
std::io::stdin()
.read_line(&mut input)
.expect("Failed to read line");
self.buf.clear();
self.buf.extend(input.as_bytes());
self.pos = 0;
return self.next();
}
from_utf8(&self.buf[start..self.pos])
.unwrap()
.parse::<T>()
.ok()
.expect(
&format!(
"Failed to parse input: {}", from_utf8(& self.buf[start
..self.pos]).unwrap()
),
)
}
#[allow(non_snake_case)]
pub fn vector<T: FromStr>(&mut self, n: usize) -> Vec<T> {
(0..n).map(|_| self.next()).collect()
}
pub fn graph(
&mut self,
n: usize,
m: usize,
is_one_way: bool,
) -> Vec<Vec<usize>> {
let mut graph = vec![Vec::new(); n];
for _ in 0..m {
let (u, v): (usize, usize) = self.pair();
graph[u - 1].push(v - 1);
if !is_one_way {
graph[v - 1].push(u - 1);
}
}
graph
}
pub fn weighted_graph<T: Copy + FromStr>(
&mut self,
n: usize,
m: usize,
is_one_way: bool,
is_one_based: bool,
) -> Vec<Vec<(usize, T)>> {
let mut graph = vec![Vec::new(); n];
for _ in 0..m {
let (u, v, w): (usize, usize, T) = self.triple();
let u = if is_one_based { u - 1 } else { u };
let v = if is_one_based { v - 1 } else { v };
graph[u].push((v, w));
if !is_one_way {
graph[v].push((u, w));
}
}
graph
}
pub fn pair<T: FromStr, U: FromStr>(&mut self) -> (T, U) {
(self.next(), self.next())
}
pub fn triple<T: FromStr, U: FromStr, V: FromStr>(
&mut self,
) -> (T, U, V) {
(self.next(), self.next(), self.next())
}
}
}
}
}