Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
json
Languages:
English
Size:
< 1K
ArXiv:
Tags:
competitive-programming
code-generation
specification-generation
proof-generation
verification
rust
License:
Download leetcode/lc1503/code_spec.rs from Gax-c/VeriContest_Lite: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/datasets/Gax-c/VeriContest_Lite/resolve/main/leetcode/lc1503/code_spec.rs
- Command line
-
hf download hf://datasets/Gax-c/VeriContest_Lite/leetcode/lc1503/code_spec.rs
-
curl -L -o code_spec.rs https://huggingface.co/datasets/Gax-c/VeriContest_Lite/resolve/main/leetcode/lc1503/code_spec.rs
1.67 kB
| use vstd::prelude::*; | |
| fn main() {} | |
| verus! { | |
| pub struct Solution; | |
| impl Solution { | |
| pub fn get_last_moment(n: i32, left: Vec<i32>, right: Vec<i32>) -> (res: i32) | |
| requires | |
| 1 <= n <= 10_000, | |
| left.len() + right.len() >= 1, | |
| left.len() + right.len() <= n + 1, | |
| forall |i: int| 0 <= i < left.len() ==> 0 <= left[i] <= n, | |
| forall |i: int| 0 <= i < right.len() ==> 0 <= right[i] <= n, | |
| forall |i: int, j: int| 0 <= i < j < left.len() ==> left[i] != left[j], | |
| forall |i: int, j: int| 0 <= i < j < right.len() ==> right[i] != right[j], | |
| forall |i: int, j: int| 0 <= i < left.len() && 0 <= j < right.len() ==> left[i] != right[j], | |
| ensures | |
| 0 <= res <= n, | |
| forall |i: int| 0 <= i < left.len() ==> res >= left[i], | |
| forall |i: int| 0 <= i < right.len() ==> res >= n - right[i], | |
| (exists |k: int| 0 <= k < left.len() && res == left[k]) | |
| || (exists |k: int| 0 <= k < right.len() && res == n - right[k]), | |
| { | |
| let mut max_left: i32 = 0; | |
| let mut i: usize = 0; | |
| while i < left.len() { | |
| if left[i] >= max_left { | |
| max_left = left[i]; | |
| } | |
| i = i + 1; | |
| } | |
| let mut min_right: i32 = n; | |
| let mut j: usize = 0; | |
| while j < right.len() { | |
| if right[j] <= min_right { | |
| min_right = right[j]; | |
| } | |
| j = j + 1; | |
| } | |
| if max_left >= n - min_right { | |
| max_left | |
| } else { | |
| n - min_right | |
| } | |
| } | |
| } | |
| } | |