Submission #25961940
Source Code Expand
#include <bits/stdc++.h>
#define ll long long
#define ft first
#define sec second
#define pb push_back
#define pf push_front
#define pr pair<ll,ll>
#define bged(a) a.begin(),a.end()
#define ISCC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#pragma optimize("Ofast","unroll-loop")
using namespace std;
const int MOD = 1e9+7;
int t ,n ,m ,a[305] ,b[305] ,A ,B ,x ,y ,dp[305][305] ,ans=1e9;
int main()
{
cin >> n;
cin >> x >> y;
for(int i=0 ;i<n ;i++) cin >> a[i] >> b[i] ,A+=a[i] ,B+=b[i];
if(A < x || B < y){cout << "-1"; return 0;}
for(int i=1 ;i<=300 ;i++) dp[i][0] = dp[0][i] = 1e9;
for(int i=1 ;i<=300 ;i++)
for(int j=1 ;j<=300 ;j++) dp[i][j] = 1e9;
for(int i=0 ;i<n ;i++)
for(int j=300 ;j>=0 ;j--)
for(int k=300 ;k>=0 ;k--) dp[j][k] = min(dp[max(0 ,j-a[i])][max(0 ,k-b[i])]+1 ,dp[j][k]);
for(int i=x ;i<=300 ;i++)
for(int j=y ;j<=300 ;j++) ans = min(dp[i][j] ,ans);
cout << ans;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Strange Lunchbox |
| User | ck1080012 |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 954 Byte |
| Status | AC |
| Exec Time | 48 ms |
| Memory | 3956 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:26:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
26 | for(int i=x ;i<=300 ;i++)
| ^~~
./Main.cpp:28:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
28 | cout << ans;
| ^~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, example0.txt, example1.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 7 ms | 3896 KiB |
| 001.txt | AC | 2 ms | 3468 KiB |
| 002.txt | AC | 2 ms | 3508 KiB |
| 003.txt | AC | 2 ms | 3380 KiB |
| 004.txt | AC | 40 ms | 3800 KiB |
| 005.txt | AC | 43 ms | 3808 KiB |
| 006.txt | AC | 41 ms | 3828 KiB |
| 007.txt | AC | 43 ms | 3888 KiB |
| 008.txt | AC | 44 ms | 3824 KiB |
| 009.txt | AC | 41 ms | 3868 KiB |
| 010.txt | AC | 3 ms | 3756 KiB |
| 011.txt | AC | 34 ms | 3872 KiB |
| 012.txt | AC | 27 ms | 3868 KiB |
| 013.txt | AC | 42 ms | 3908 KiB |
| 014.txt | AC | 43 ms | 3892 KiB |
| 015.txt | AC | 41 ms | 3868 KiB |
| 016.txt | AC | 44 ms | 3956 KiB |
| 017.txt | AC | 43 ms | 3956 KiB |
| 018.txt | AC | 31 ms | 3828 KiB |
| 019.txt | AC | 18 ms | 3872 KiB |
| 020.txt | AC | 39 ms | 3732 KiB |
| 021.txt | AC | 20 ms | 3888 KiB |
| 022.txt | AC | 39 ms | 3888 KiB |
| 023.txt | AC | 24 ms | 3892 KiB |
| 024.txt | AC | 36 ms | 3760 KiB |
| 025.txt | AC | 17 ms | 3892 KiB |
| 026.txt | AC | 38 ms | 3888 KiB |
| 027.txt | AC | 40 ms | 3892 KiB |
| 028.txt | AC | 2 ms | 3380 KiB |
| 029.txt | AC | 2 ms | 3516 KiB |
| 030.txt | AC | 29 ms | 3804 KiB |
| 031.txt | AC | 40 ms | 3760 KiB |
| 032.txt | AC | 34 ms | 3868 KiB |
| 033.txt | AC | 32 ms | 3888 KiB |
| 034.txt | AC | 36 ms | 3892 KiB |
| 035.txt | AC | 41 ms | 3888 KiB |
| 036.txt | AC | 32 ms | 3892 KiB |
| 037.txt | AC | 31 ms | 3796 KiB |
| 038.txt | AC | 2 ms | 3536 KiB |
| 039.txt | AC | 2 ms | 3444 KiB |
| 040.txt | AC | 2 ms | 3512 KiB |
| 041.txt | AC | 6 ms | 3732 KiB |
| 042.txt | AC | 3 ms | 3804 KiB |
| 043.txt | AC | 7 ms | 3872 KiB |
| 044.txt | AC | 41 ms | 3868 KiB |
| 045.txt | AC | 2 ms | 3376 KiB |
| 046.txt | AC | 48 ms | 3872 KiB |
| 047.txt | AC | 2 ms | 3440 KiB |
| example0.txt | AC | 3 ms | 3756 KiB |
| example1.txt | AC | 3 ms | 3484 KiB |