Submission #00123
ソースコード
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | #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" ; return (0); } if (15<n&&n<=1000){ vector<pair< int , int >>s(n); vector< int >f(3,0); for ( int i=0;i<n;i++){ cin>>s[i].first>>s[i].second; if (s[i].second<=2){ f[s[i].second]++; } else { return (0); ///////////////////////////////// } } sort(s.begin(),s.end()); vector< int >v,u; if (f[1]==0){ for ( int i=0;i<n;i++){ if (i==0||v[v.size()-1]+d<=s[i].first){ v.push_back(s[i].first); } } if (v.size()>=m){ cout<<2<< "\n" ; } else { cout<<0<< "\n" ; } return (0); } else { for ( int i=0;i<n;i++){ if (i==0||v[v.size()-1]+d<=s[i].first&&s[i].second==2){ v.push_back(s[i].first); } } for ( int i=0;i<n;i++){ if (i==0||u[u.size()-1]+d<=s[i].first){ u.push_back(s[i].first); } } if (v.size()>=m){ cout<<2<< "\n" ; } else if (u.size()>=m){ cout<<1<< "\n" ; } else { cout<<0<< "\n" ; } return (0); } } } |
ステータス
項目 | データ |
---|---|
問題 | 0009 - 展覧会 2 (Exhibition 2) |
ユーザー名 | ei2326 |
投稿日時 | 2023-11-14 09:47:04 |
言語 | C++17 |
状態 | Wrong Answer |
得点 | 34 |
ソースコード長 | 3157 Byte |
最大実行時間 | 82 ms |
最大メモリ使用量 | 2212 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 | 26 ms | 604 KB |
1
|
|||||
01-02.txt | AC | 28 ms | 448 KB |
1
|
|||||
01-03.txt | AC | 22 ms | 544 KB |
1
|
|||||
01-04.txt | AC | 26 ms | 512 KB |
1
|
|||||
01-05.txt | AC | 61 ms | 2016 KB |
1
|
|||||
01-06.txt | AC | 72 ms | 1960 KB |
1
|
|||||
01-07.txt | AC | 65 ms | 2032 KB |
1
|
|||||
02-01.txt | AC | 24 ms | 700 KB |
2
|
|||||
02-02.txt | AC | 20 ms | 672 KB |
2
|
|||||
02-03.txt | AC | 80 ms | 2056 KB |
2
|
|||||
02-04.txt | AC | 70 ms | 2124 KB |
2
|
|||||
02-05.txt | AC | 82 ms | 2072 KB |
2
|
|||||
02-06.txt | AC | 73 ms | 2144 KB |
2
|
|||||
02-07.txt | AC | 68 ms | 2212 KB |
2
|
|||||
02-08.txt | AC | 68 ms | 2032 KB |
2
|
|||||
03-01.txt | AC | 27 ms | 568 KB |
3
|
|||||
03-02.txt | AC | 26 ms | 544 KB |
3
|
|||||
03-03.txt | AC | 32 ms | 520 KB |
3
|
|||||
03-04.txt | AC | 30 ms | 628 KB |
3
|
|||||
03-05.txt | AC | 31 ms | 604 KB |
3
|
|||||
03-06.txt | AC | 33 ms | 580 KB |
3
|
|||||
04-01.txt | AC | 23 ms | 544 KB |
4
|
|||||
04-02.txt | WA | 19 ms | 616 KB |
4
|
|||||
04-03.txt | AC | 22 ms | 560 KB |
4
|
|||||
04-04.txt | AC | 16 ms | 508 KB |
4
|
|||||
04-05.txt | AC | 21 ms | 708 KB |
4
|
|||||
04-06.txt | WA | 21 ms | 656 KB |
4
|
|||||
04-07.txt | WA | 21 ms | 600 KB |
4
|
|||||
05-01.txt | WA | 22 ms | 676 KB |
5
|
|||||
05-02.txt | WA | 24 ms | 636 KB |
5
|
|||||
05-03.txt | WA | 20 ms | 724 KB |
5
|
|||||
05-04.txt | WA | 16 ms | 680 KB |
5
|
|||||
05-05.txt | AC | 21 ms | 768 KB |
5
|
|||||
05-06.txt | AC | 20 ms | 592 KB |
5
|
|||||
05-07.txt | WA | 23 ms | 424 KB |
5
|
|||||
05-08.txt | WA | 29 ms | 644 KB |
5
|
|||||
05-09.txt | WA | 27 ms | 604 KB |
5
|
|||||
05-10.txt | WA | 25 ms | 560 KB |
5
|
|||||
05-11.txt | WA | 28 ms | 524 KB |
5
|
|||||
05-12.txt | WA | 17 ms | 612 KB |
5
|
|||||
06-01.txt | WA | 23 ms | 572 KB |
6
|
|||||
06-02.txt | WA | 21 ms | 548 KB |
6
|
|||||
06-03.txt | WA | 20 ms | 656 KB |
6
|
|||||
06-04.txt | WA | 20 ms | 504 KB |
6
|
|||||
06-05.txt | WA | 28 ms | 740 KB |
6
|
|||||
06-06.txt | WA | 24 ms | 708 KB |
6
|
|||||
06-07.txt | WA | 28 ms | 680 KB |
6
|
|||||
06-08.txt | WA | 25 ms | 652 KB |
6
|
|||||
06-09.txt | WA | 24 ms | 628 KB |
6
|
|||||
06-10.txt | WA | 18 ms | 476 KB |
6
|
|||||
06-11.txt | WA | 24 ms | 580 KB |
6
|
|||||
06-12.txt | WA | 25 ms | 684 KB |
6
|
|||||
06-13.txt | WA | 24 ms | 784 KB |
6
|
|||||
06-14.txt | WA | 20 ms | 628 KB |
6
|
|||||
06-15.txt | WA | 19 ms | 604 KB |
6
|
|||||
06-16.txt | WA | 30 ms | 708 KB |
6
|
|||||
06-17.txt | WA | 22 ms | 560 KB |
6
|
|||||
06-18.txt | WA | 22 ms | 664 KB |
6
|
|||||
06-19.txt | WA | 22 ms | 644 KB |
6
|
|||||
06-20.txt | WA | 14 ms | 744 KB |
6
|
|||||
06-21.txt | WA | 16 ms | 592 KB |
6
|
|||||
06-22.txt | WA | 21 ms | 564 KB |
6
|