# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766958 | 2023-06-26T09:36:45 Z | birthdaycake | Fruits (NOI22_fruits) | C++14 | 1000 ms | 17460 KB |
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <fstream> #define endl '\n' #define int long long #define mod 1000000007 using namespace std; int a[400001],c[400001]; int ans[400001]; signed main(){ int n; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) cin >> c[i]; vector<int>d; for(int i = 1; i <= n; i++) d.push_back(i); do{ int cur = 0, mx = 0, bad = 0; vector<int>f; for(int i = 0; i < n; i++){ if(a[i + 1] == -1){ if(d[i] > mx){ mx = d[i]; cur += c[d[i]]; } }else{ if(d[i] != a[i + 1]) bad = 1; if(d[i] > mx){ mx = d[i]; cur += c[d[i]]; } } f.push_back(cur); } if(!bad){ for(int i = 0; i < f.size(); i++){ ans[i] = max(ans[i],f[i]); } } }while(next_permutation(d.begin(), d.end())); for(int i = 0; i < n; i++) cout << ans[i] << ' '; } /* 2 4 1 1 4 3 1 3 2 1 1 2 2 3 3 2 1 2 2 4 1 1 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 212 KB | Output is correct |
3 | Correct | 5 ms | 224 KB | Output is correct |
4 | Correct | 5 ms | 320 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 5 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 5 ms | 232 KB | Output is correct |
10 | Correct | 5 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1081 ms | 212 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 212 KB | Output is correct |
3 | Correct | 5 ms | 224 KB | Output is correct |
4 | Correct | 5 ms | 320 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 5 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 5 ms | 232 KB | Output is correct |
10 | Correct | 5 ms | 212 KB | Output is correct |
11 | Execution timed out | 1078 ms | 212 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 212 KB | Output is correct |
3 | Correct | 5 ms | 224 KB | Output is correct |
4 | Correct | 5 ms | 320 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 5 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 5 ms | 232 KB | Output is correct |
10 | Correct | 5 ms | 212 KB | Output is correct |
11 | Execution timed out | 1078 ms | 212 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1018 ms | 17460 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 212 KB | Output is correct |
3 | Correct | 5 ms | 224 KB | Output is correct |
4 | Correct | 5 ms | 320 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 5 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 5 ms | 232 KB | Output is correct |
10 | Correct | 5 ms | 212 KB | Output is correct |
11 | Execution timed out | 1081 ms | 212 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |