QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#302263 | #7950. Lucky Draws | mariowong# | WA | 1163ms | 5640kb | C++17 | 736b | 2024-01-10 18:15:55 | 2024-01-10 18:15:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n,m;
cin >> n >> m;
vector <pair<int,int> > a(n+1);
vector <int> mx(n+1);
for (int i=1;i<=n;i++) cin >> a[i].first >> a[i].second;
sort(a.begin()+1,a.end());
for (int i=1;i<=n;i++) mx[i]=max(mx[i-1],a[i].second);
vector <vector<int> > dp(n+1,vector<int>(m+1));
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
int cnt=0;
for (int k=i;k>=1;k--){
if (mx[k] < a[i].first)
break;
if (a[i].first <= a[k].second)
cnt++;
dp[i][j]=max(dp[i][j],dp[k-1][j-1]+cnt);
}
// cout << dp[i][j] << " ";
}
//cout << "\n";
}
cout << dp[n][m] << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3436kb
input:
5 2 1 2 1 4 3 6 4 7 5 6
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
3 2 2 4 1 3 3 5
output:
3
result:
ok single line: '3'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
4 1 2 3 1 1 4 5 4 5
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
7 2 5 6 7 9 7 7 1 4 2 3 4 7 4 7
output:
6
result:
ok single line: '6'
Test #5:
score: -100
Wrong Answer
time: 1163ms
memory: 5640kb
input:
10000 50 -16187 -16186 743439 743441 -995450 -995449 921242 921242 -287646 -287644 110263 110264 650110 650110 897150 897151 262837 262839 935191 935193 6079 6080 815160 815162 -624776 -624774 -782088 -782086 486051 486052 -704289 -704287 -592330 -592329 -943804 -943803 43046 43047 -896912 -896910 -...
output:
50
result:
wrong answer 1st lines differ - expected: '100', found: '50'