Submission #438441

#TimeUsernameProblemLanguageResultExecution timeMemory
438441KazamaHoangBank (IZhO14_bank)C++14
0 / 100
1 ms204 KiB
/* -> Written by <- ----------- |K_A_Z_A_M_A| |___________| | ___ | | (^_^) | | /( | )\ | |____|_|____| H O A N G */ #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using namespace std; //using namespace __gnu_pbds; using ll = long long; using db = long double; //using int = long long #define Task "" #define F first #define S second #define eb emplace_back #define sz(x) ((int)x.size()) #define all(x) x.begin(), x.end() #define sall(x, n) x.begin() + 1, x.end() + 1 + n #define bit(x, i) (((x) >> (i)) & 1) #define endl '\n' #define fr(i,a,b) for (int i = (int)(a); i <= (int)(b); ++ i) #define FR(i,a,b) for (int i = (int)(a); i < (int)(b); ++ i) #define frr(i,a,b) for (int i = (int)(a); i >= (int)(b); -- i) #define fre(i, a) for (auto &i : a) // #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef ONLINE_JUDGE #define debug(x...) {cerr << "[" << #x << "] = ["; _print(x); } #else #define debug(x...) #endif const int MOD = 1e9 + 7; const ll MM = (ll)MOD * MOD; const int base = 1e6; const int B = 32; const int inf = 1e9 + 7; const ll INF = 1e18 + 7; const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; const int dy8[] = {1, -1, 0, 1, -1, 0, 1, -1}; const int dx4[] = {0, 0, 1, -1}; const int dy4[] = {1, -1, 0, 0}; // code go here int n, m; int a[25], b[25], id[25]; void solve(int tc) { cin >> n >> m; fr(i, 1, n) cin >> a[i]; fr(i, 1, m) cin >> b[i], id[i] = i; do { int s = 0, x = 1; fr(i, 1, m) { int u = id[i]; s += b[u]; if (x <= n && s == a[x]) ++ x, s = 0; } if (x == n) { cout << "YES\n"; return; } } while (next_permutation(id + 1, id + 1 + n)); cout << "NO\n"; } signed main(){ cin.tie(0)->sync_with_stdio(0); if (fopen(".in", "r")) { freopen(".in", "r", stdin); freopen(".out", "w", stdout); freopen(".log", "w", stderr); } else if (fopen(Task".in", "r")) { freopen(Task".in", "r", stdin); freopen(Task".out", "w", stdout); } int test_case = 1; // cin >> test_case; // prepare(); fr(i, 1, test_case) { solve(i); // bf(); } return 0; } // try your best !!!

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:104:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  104 |         freopen(".in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
bank.cpp:105:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |         freopen(".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         freopen(".log", "w", stderr);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:109:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  109 |         freopen(Task".in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:110:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  110 |         freopen(Task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...