Submission #00121
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #include<bits/stdc++.h> using namespace std; int main(){ #define int long long int n,m,d;cin>>n>>m>>d; if (m==1){ int ma=0; vector<pair< int , int >>s(n); for ( int i=0;i<n;i++){ cin>>s[i].first>>s[i].second; ma=max(ma,s[i].second); } cout<<ma<< "\n" ; return (0); } if (n==m){ vector<pair< int , int >>s(n); for ( int i=0;i<n;i++){ cin>>s[i].first>>s[i].second; } int ma=INT_MAX; sort(s.begin(),s.end()); for ( int i=0;i<n-1;i++){ if (s[i+1].first-s[i].first<d){ cout<< "-1\n" ; return (0); } ma=min(ma,s[i].second); ma=min(ma,s[i+1].second); } cout<<ma<< "\n" ; return (0); } if (n<=15){ int ans=-1; vector<pair< int , int >>s(n); for ( int i=0;i<n;i++){ cin>>s[i].first>>s[i].second; } sort(s.begin(),s.end()); for ( int i=0;i<(1<<n);i++){ int k=LONG_LONG_MAX,h=0; vector<pair< int , int >>v; for ( int j=0;j<n;j++){ if (i&(1<<j)){ h++; v.push_back(s[j]); } } if (h==m){ sort(v.begin(),v.end()); bool y= true ; for ( int j=0;j<m-1;j++){ if (v[j+1].first-v[j].first<d){ y= false ; break ; } k=min(k,v[j].second); k=min(k,v[j+1].second); } if (y){ //cout<<i<<" "<<k<<"\n"; ans=max(ans,k); } } } cout<<ans<< "\n" ; } } |
ステータス
項目 | データ |
---|---|
問題 | 0009 - 展覧会 2 (Exhibition 2) |
ユーザー名 | ei2326 |
投稿日時 | 2023-11-14 08:35:29 |
言語 | C++17 |
状態 | Wrong Answer |
得点 | 34 |
ソースコード長 | 1892 Byte |
最大実行時間 | 78 ms |
最大メモリ使用量 | 2216 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | 01 | 3 / 3 | 01* |
2 | 02 | 12 / 12 | 02* |
3 | 03 | 19 / 19 | 03* |
4 | 04 | 0 / 17 | 04* |
5 | 05 | 0 / 22 | 05* |
6 | 06 | 0 / 27 | 06* |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |||||
---|---|---|---|---|---|---|---|---|---|
01-01.txt | AC | 30 ms | 604 KB |
1
|
|||||
01-02.txt | AC | 28 ms | 576 KB |
1
|
|||||
01-03.txt | AC | 31 ms | 424 KB |
1
|
|||||
01-04.txt | AC | 28 ms | 524 KB |
1
|
|||||
01-05.txt | AC | 58 ms | 1908 KB |
1
|
|||||
01-06.txt | AC | 65 ms | 2104 KB |
1
|
|||||
01-07.txt | AC | 76 ms | 2172 KB |
1
|
|||||
02-01.txt | AC | 16 ms | 580 KB |
2
|
|||||
02-02.txt | AC | 21 ms | 552 KB |
2
|
|||||
02-03.txt | AC | 73 ms | 2184 KB |
2
|
|||||
02-04.txt | AC | 71 ms | 2128 KB |
2
|
|||||
02-05.txt | AC | 78 ms | 2076 KB |
2
|
|||||
02-06.txt | AC | 72 ms | 2148 KB |
2
|
|||||
02-07.txt | AC | 69 ms | 2216 KB |
2
|
|||||
02-08.txt | AC | 69 ms | 2156 KB |
2
|
|||||
03-01.txt | AC | 27 ms | 436 KB |
3
|
|||||
03-02.txt | AC | 24 ms | 536 KB |
3
|
|||||
03-03.txt | AC | 25 ms | 508 KB |
3
|
|||||
03-04.txt | AC | 27 ms | 484 KB |
3
|
|||||
03-05.txt | AC | 27 ms | 584 KB |
3
|
|||||
03-06.txt | AC | 32 ms | 556 KB |
3
|
|||||
04-01.txt | WA | 17 ms | 528 KB |
4
|
|||||
04-02.txt | WA | 21 ms | 632 KB |
4
|
|||||
04-03.txt | WA | 17 ms | 604 KB |
4
|
|||||
04-04.txt | WA | 25 ms | 576 KB |
4
|
|||||
04-05.txt | WA | 18 ms | 548 KB |
4
|
|||||
04-06.txt | WA | 20 ms | 524 KB |
4
|
|||||
04-07.txt | WA | 22 ms | 504 KB |
4
|
|||||
05-01.txt | WA | 17 ms | 484 KB |
5
|
|||||
05-02.txt | WA | 30 ms | 584 KB |
5
|
|||||
05-03.txt | WA | 21 ms | 560 KB |
5
|
|||||
05-04.txt | WA | 20 ms | 536 KB |
5
|
|||||
05-05.txt | AC | 20 ms | 644 KB |
5
|
|||||
05-06.txt | AC | 18 ms | 600 KB |
5
|
|||||
05-07.txt | WA | 21 ms | 556 KB |
5
|
|||||
05-08.txt | WA | 17 ms | 524 KB |
5
|
|||||
05-09.txt | WA | 27 ms | 632 KB |
5
|
|||||
05-10.txt | WA | 22 ms | 612 KB |
5
|
|||||
05-11.txt | WA | 24 ms | 592 KB |
5
|
|||||
05-12.txt | WA | 20 ms | 692 KB |
5
|
|||||
06-01.txt | WA | 22 ms | 544 KB |
6
|
|||||
06-02.txt | WA | 22 ms | 644 KB |
6
|
|||||
06-03.txt | WA | 20 ms | 620 KB |
6
|
|||||
06-04.txt | WA | 27 ms | 720 KB |
6
|
|||||
06-05.txt | WA | 17 ms | 564 KB |
6
|
|||||
06-06.txt | WA | 25 ms | 536 KB |
6
|
|||||
06-07.txt | WA | 19 ms | 508 KB |
6
|
|||||
06-08.txt | WA | 21 ms | 484 KB |
6
|
|||||
06-09.txt | WA | 23 ms | 588 KB |
6
|
|||||
06-10.txt | WA | 19 ms | 692 KB |
6
|
|||||
06-11.txt | WA | 18 ms | 668 KB |
6
|
|||||
06-12.txt | WA | 22 ms | 644 KB |
6
|
|||||
06-13.txt | WA | 20 ms | 624 KB |
6
|
|||||
06-14.txt | WA | 17 ms | 472 KB |
6
|
|||||
06-15.txt | WA | 26 ms | 572 KB |
6
|
|||||
06-16.txt | WA | 20 ms | 548 KB |
6
|
|||||
06-17.txt | WA | 22 ms | 524 KB |
6
|
|||||
06-18.txt | WA | 19 ms | 628 KB |
6
|
|||||
06-19.txt | WA | 20 ms | 468 KB |
6
|
|||||
06-20.txt | WA | 20 ms | 568 KB |
6
|
|||||
06-21.txt | WA | 21 ms | 548 KB |
6
|
|||||
06-22.txt | WA | 17 ms | 648 KB |
6
|