# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
278027 | 2020-08-21T09:01:00 Z | 반딧불(#5119) | Shopping Plans (CCO20_day2problem3) | C++17 | 4000 ms | 679952 KB |
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; struct dat{ ll a, b, c, d; dat(ll a, ll b, ll c, ll d): a(a), b(b), c(c), d(d){} bool operator<(const dat &r)const{ return a>r.a; } }; int n, m, k; vector<ll> arr[4002]; priority_queue<dat> pq; ll ans[4002]; ll weight[4002]; vector<int> ansVec[4002]; unordered_set<ll> st; ll sum = 0; int main(){ scanf("%d %d %d", &n, &m, &k); for(int i=1; i<=n; i++){ int x; ll y; scanf("%d %lld", &x, &y); arr[x].push_back(y); } for(int i=1; i<=m; i++){ int x, y; scanf("%d %d", &x, &y); } for(int i=1; i<=m; i++) sort(arr[i].begin(), arr[i].end()); for(int i=1; i<=m; i++){ if(arr[i].empty()){ while(k--) printf("-1\n"); return 0; } sum += arr[i][0]; } for(int i=0; i<m; i++){ weight[i] = rand(); } vector<int> zeroVec (m, 0); st.insert(0); pq.push(dat(sum, 0, 0, 0)); for(int d=1; d<=k; d++){ // printf("%d ", d); if(pq.empty()) break; auto tmp = pq.top(); pq.pop(); vector<int> tv; if(!tmp.b) tv = zeroVec; else{ tv = ansVec[tmp.b]; tv[tmp.c]++; } ansVec[d] = tv; ans[d] = tmp.a; for(int i=0; i<m; i++){ if(tv[i] == (int)arr[i+1].size()-1) continue; tv[i]++; ll tsh = tmp.d + weight[i] * (arr[i+1][tv[i]] - arr[i+1][tv[i]-1]); if(st.find(tsh) == st.end()) st.insert(tsh), pq.push(dat(tmp.a + arr[i+1][tv[i]] - arr[i+1][tv[i]-1], d, i, tsh)); tv[i]--; } } for(int d=1; d<=k; d++){ printf("%lld\n", ans[d] ? ans[d] : -1); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2838 ms | 323844 KB | Output is correct |
2 | Correct | 2276 ms | 252536 KB | Output is correct |
3 | Correct | 2831 ms | 316652 KB | Output is correct |
4 | Correct | 438 ms | 73040 KB | Output is correct |
5 | Correct | 2805 ms | 325120 KB | Output is correct |
6 | Execution timed out | 4128 ms | 482148 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3040 ms | 679952 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2838 ms | 323844 KB | Output is correct |
2 | Correct | 2276 ms | 252536 KB | Output is correct |
3 | Correct | 2831 ms | 316652 KB | Output is correct |
4 | Correct | 438 ms | 73040 KB | Output is correct |
5 | Correct | 2805 ms | 325120 KB | Output is correct |
6 | Execution timed out | 4128 ms | 482148 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 1152 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2838 ms | 323844 KB | Output is correct |
2 | Correct | 2276 ms | 252536 KB | Output is correct |
3 | Correct | 2831 ms | 316652 KB | Output is correct |
4 | Correct | 438 ms | 73040 KB | Output is correct |
5 | Correct | 2805 ms | 325120 KB | Output is correct |
6 | Execution timed out | 4128 ms | 482148 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |