complete jungol/3521.cpp jungol/4520.cpp qoj/1.cpp
This commit is contained in:
47
storage/jungol/cpp/3521.cpp
Normal file
47
storage/jungol/cpp/3521.cpp
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#define let auto
|
||||||
|
#define fn auto
|
||||||
|
#define usize size_t
|
||||||
|
#define u64 uint64_t
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
fn fastio() {
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> int {
|
||||||
|
fastio();
|
||||||
|
|
||||||
|
let grams = vector<u64>{1, 2, 4, 8, 16};
|
||||||
|
let counts = vector<u64>(5);
|
||||||
|
|
||||||
|
for (usize i = 0; i < 5; i++) {
|
||||||
|
cin >> counts[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
usize n;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
let usage = 0;
|
||||||
|
let i = 4;
|
||||||
|
while (i >= 0 && n > 0) {
|
||||||
|
if (counts[i] > 0 && n >= grams[i]) {
|
||||||
|
n -= grams[i];
|
||||||
|
counts[i] -= 1;
|
||||||
|
usage += 1;
|
||||||
|
} else {
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n != 0) {
|
||||||
|
cout << "impossible" << endl;
|
||||||
|
} else {
|
||||||
|
cout << usage << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
50
storage/jungol/cpp/4520.cpp
Normal file
50
storage/jungol/cpp/4520.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#define let auto
|
||||||
|
#define fn auto
|
||||||
|
typedef size_t usize;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
fn fastio() {
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> int {
|
||||||
|
usize n, k;
|
||||||
|
cin >> n >> k;
|
||||||
|
let line = vector<char>(n);
|
||||||
|
let valid = vector<bool>(n, false);
|
||||||
|
for (usize i = 0; i < n; i++) {
|
||||||
|
char t;
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
line[i] = t;
|
||||||
|
if (t == 'H') {
|
||||||
|
valid[i] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// left assoc
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
for (usize i = 0; i < n; i++) {
|
||||||
|
if (line[i] == 'P') {
|
||||||
|
let left = i >= k ? i - k : 0;
|
||||||
|
let right = i + k >= n ? n - 1 : i + k;
|
||||||
|
|
||||||
|
for (usize j = left; j <= right; j++) {
|
||||||
|
if (valid[j]) {
|
||||||
|
count += 1;
|
||||||
|
valid[j] = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << count << endl;
|
||||||
|
}
|
||||||
39
storage/qoj/cpp/1.cpp
Normal file
39
storage/qoj/cpp/1.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#define let auto
|
||||||
|
#define fn auto
|
||||||
|
#define usize size_t
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
fn fastio() {
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
fn main() -> int {
|
||||||
|
fastio();
|
||||||
|
usize n, s = 0, t;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
for (usize i = 0; i < n; i++) {
|
||||||
|
cin >> t;
|
||||||
|
s += t;
|
||||||
|
}
|
||||||
|
cout << s << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
fn main() -> int {
|
||||||
|
fastio();
|
||||||
|
usize k = 100'000'008;
|
||||||
|
usize n;
|
||||||
|
cin >> n;
|
||||||
|
for (usize i = 0; i < n; i++) {
|
||||||
|
cout << k << " ";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user