Submission #00118
ソースコード
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 | #include<bits/stdc++.h> using namespace std; int main(){ #define int long long int n,m,d;cin>>n>>m>>d; 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" ; } else 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" ; } else 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=INT_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); } if (y){ //cout<<i<<" "<<k<<"\n"; ans=max(ans,k); } } } cout<<ans<< "\n" ; } } |
ステータス
項目 | データ |
---|---|
問題 | 0009 - 展覧会 2 (Exhibition 2) |
ユーザー名 | ei2326 |
投稿日時 | 2023-11-14 08:31:21 |
言語 | C++17 |
状態 | Wrong Answer |
得点 | 12 |
ソースコード長 | 1799 Byte |
最大実行時間 | 134 ms |
最大メモリ使用量 | 2204 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | 01 | 0 / 3 | 01* |
2 | 02 | 12 / 12 | 02* |
3 | 03 | 0 / 19 | 03* |
4 | 04 | 0 / 17 | 04* |
5 | 05 | 0 / 22 | 05* |
6 | 06 | 0 / 27 | 06* |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |||||
---|---|---|---|---|---|---|---|---|---|
01-01.txt | WA | 33 ms | 600 KB |
1
|
|||||
01-02.txt | AC | 23 ms | 444 KB |
1
|
|||||
01-03.txt | AC | 21 ms | 412 KB |
1
|
|||||
01-04.txt | AC | 25 ms | 512 KB |
1
|
|||||
01-05.txt | AC | 66 ms | 2148 KB |
1
|
|||||
01-06.txt | AC | 63 ms | 2092 KB |
1
|
|||||
01-07.txt | AC | 71 ms | 2168 KB |
1
|
|||||
02-01.txt | AC | 26 ms | 444 KB |
2
|
|||||
02-02.txt | AC | 16 ms | 420 KB |
2
|
|||||
02-03.txt | AC | 77 ms | 2188 KB |
2
|
|||||
02-04.txt | AC | 134 ms | 2136 KB |
2
|
|||||
02-05.txt | AC | 74 ms | 2204 KB |
2
|
|||||
02-06.txt | AC | 71 ms | 2148 KB |
2
|
|||||
02-07.txt | AC | 75 ms | 2092 KB |
2
|
|||||
02-08.txt | AC | 67 ms | 2036 KB |
2
|
|||||
03-01.txt | AC | 27 ms | 448 KB |
3
|
|||||
03-02.txt | AC | 31 ms | 548 KB |
3
|
|||||
03-03.txt | AC | 28 ms | 648 KB |
3
|
|||||
03-04.txt | WA | 35 ms | 744 KB |
3
|
|||||
03-05.txt | AC | 29 ms | 588 KB |
3
|
|||||
03-06.txt | AC | 33 ms | 560 KB |
3
|
|||||
04-01.txt | WA | 24 ms | 656 KB |
4
|
|||||
04-02.txt | WA | 15 ms | 632 KB |
4
|
|||||
04-03.txt | WA | 18 ms | 604 KB |
4
|
|||||
04-04.txt | WA | 20 ms | 580 KB |
4
|
|||||
04-05.txt | WA | 20 ms | 552 KB |
4
|
|||||
04-06.txt | WA | 20 ms | 652 KB |
4
|
|||||
04-07.txt | WA | 22 ms | 620 KB |
4
|
|||||
05-01.txt | WA | 25 ms | 596 KB |
5
|
|||||
05-02.txt | WA | 26 ms | 572 KB |
5
|
|||||
05-03.txt | WA | 19 ms | 544 KB |
5
|
|||||
05-04.txt | WA | 27 ms | 524 KB |
5
|
|||||
05-05.txt | AC | 22 ms | 628 KB |
5
|
|||||
05-06.txt | AC | 24 ms | 708 KB |
5
|
|||||
05-07.txt | WA | 20 ms | 660 KB |
5
|
|||||
05-08.txt | WA | 21 ms | 632 KB |
5
|
|||||
05-09.txt | WA | 22 ms | 608 KB |
5
|
|||||
05-10.txt | WA | 25 ms | 588 KB |
5
|
|||||
05-11.txt | WA | 20 ms | 568 KB |
5
|
|||||
05-12.txt | WA | 24 ms | 668 KB |
5
|
|||||
06-01.txt | WA | 23 ms | 516 KB |
6
|
|||||
06-02.txt | WA | 21 ms | 496 KB |
6
|
|||||
06-03.txt | WA | 21 ms | 596 KB |
6
|
|||||
06-04.txt | WA | 21 ms | 700 KB |
6
|
|||||
06-05.txt | WA | 19 ms | 672 KB |
6
|
|||||
06-06.txt | WA | 19 ms | 644 KB |
6
|
|||||
06-07.txt | WA | 21 ms | 488 KB |
6
|
|||||
06-08.txt | WA | 21 ms | 464 KB |
6
|
|||||
06-09.txt | WA | 23 ms | 564 KB |
6
|
|||||
06-10.txt | WA | 20 ms | 536 KB |
6
|
|||||
06-11.txt | WA | 24 ms | 636 KB |
6
|
|||||
06-12.txt | WA | 25 ms | 616 KB |
6
|
|||||
06-13.txt | WA | 20 ms | 588 KB |
6
|
|||||
06-14.txt | WA | 21 ms | 692 KB |
6
|
|||||
06-15.txt | WA | 22 ms | 672 KB |
6
|
|||||
06-16.txt | WA | 24 ms | 652 KB |
6
|
|||||
06-17.txt | WA | 20 ms | 628 KB |
6
|
|||||
06-18.txt | WA | 23 ms | 608 KB |
6
|
|||||
06-19.txt | WA | 20 ms | 588 KB |
6
|
|||||
06-20.txt | WA | 14 ms | 564 KB |
6
|
|||||
06-21.txt | WA | 21 ms | 672 KB |
6
|
|||||
06-22.txt | WA | 20 ms | 648 KB |
6
|