This commit is contained in:
parent
4ecaabd374
commit
2af004b8d0
|
@ -1,7 +1,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include<algorithm>
|
#include<algorithm>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int n,a[100000]={0};
|
int n,a[100000]={0};
|
||||||
|
|
||||||
int mins(){
|
int mins(){
|
||||||
if(a[n-2]-a[0]==n-2&&a[n-1]-a[n-2]>n-2){
|
if(a[n-2]-a[0]==n-2&&a[n-1]-a[n-2]>n-2){
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -19,6 +21,7 @@ int mins(){
|
||||||
}
|
}
|
||||||
return n-ans;
|
return n-ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
cin >> n;
|
cin >> n;
|
||||||
|
@ -28,4 +31,5 @@ int main()
|
||||||
sort(a,a+n);
|
sort(a,a+n);
|
||||||
cout<<mins()<<endl;
|
cout<<mins()<<endl;
|
||||||
cout << max(a[n-2]-a[0],a[n-1]-a[1])-n+2;
|
cout << max(a[n-2]-a[0],a[n-1]-a[1])-n+2;
|
||||||
|
return 0;
|
||||||
}
|
}
|
Binary file not shown.
|
@ -1,28 +1,28 @@
|
||||||
## z:\Chao\src\4081_npeople\test\in.txt
|
## z:\Chao\src\4081_npeople\test\in.txt
|
||||||
2020/04/10 周五 18:06:23.63
|
2020/06/13 ÖÜÁù 11:03:12.33
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 330 ms with return value 0
|
Process exited after 160 ms with return value 0
|
||||||
|
|
||||||
## z:\Chao\src\4081_npeople\test\In1 (16).txt
|
## z:\Chao\src\4081_npeople\test\In1 (16).txt
|
||||||
2020/04/10 周五 18:06:23.63
|
2020/06/13 ÖÜÁù 11:03:12.33
|
||||||
2
|
2
|
||||||
499999999
|
499999999
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 100 ms with return value 0
|
Process exited after 120 ms with return value 0
|
||||||
|
|
||||||
## z:\Chao\src\4081_npeople\test\In2 (8).txt
|
## z:\Chao\src\4081_npeople\test\In2 (8).txt
|
||||||
2020/04/10 周五 18:06:23.63
|
2020/06/13 ÖÜÁù 11:03:12.33
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 100 ms with return value 0
|
Process exited after 100 ms with return value 0
|
||||||
|
|
||||||
## z:\Chao\src\4081_npeople\test\in2.txt
|
## z:\Chao\src\4081_npeople\test\in2.txt
|
||||||
2020/04/10 周五 18:06:23.63
|
2020/06/13 ÖÜÁù 11:03:12.33
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 90 ms with return value 0
|
Process exited after 100 ms with return value 0
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,6 +1,43 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::cout << "Hello Easy C++ project!" << std::endl;
|
int n, m, rdui[100001] = { 0 }, jiad = 0, fud = 0;
|
||||||
|
bool dui[100001] = { 0 };
|
||||||
|
cin >> n >> m;
|
||||||
|
for (int i = 1; i <= m; i++) {
|
||||||
|
int yi, er;
|
||||||
|
char u;
|
||||||
|
cin >> u >> yi >> er;
|
||||||
|
if (rdui[yi] == 0 && rdui[er] == 0) {
|
||||||
|
jiad++;
|
||||||
|
rdui[yi] = jiad;
|
||||||
|
rdui[er] = jiad;
|
||||||
|
}
|
||||||
|
if (rdui[yi] != 0 && rdui[er] == 0) {
|
||||||
|
rdui[er] = rdui[yi];
|
||||||
|
}
|
||||||
|
if (rdui[yi] == 0 && rdui[er] != 0) {
|
||||||
|
rdui[yi] = rdui[er];
|
||||||
|
}
|
||||||
|
if (rdui[yi] != 0, rdui[er] != 0) {
|
||||||
|
fud++;
|
||||||
|
if (dui[rdui[yi]] == 0 && dui[rdui[er]] == 0) {
|
||||||
|
dui[rdui[er]] = 1;
|
||||||
|
} else {
|
||||||
|
if (dui[rdui[yi]] == 1 && dui[rdui[er]] == 1) {
|
||||||
|
fud--;
|
||||||
|
} else {
|
||||||
|
dui[rdui[yi]] = dui[rdui[er]] == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ll = jiad - fud;
|
||||||
|
cout << "1";
|
||||||
|
for (int i = 1; i <= ll; i++) {
|
||||||
|
cout << "0";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -1,18 +1,18 @@
|
||||||
## z:\Chao\src\4083_mit\test\in.txt
|
## z:\Chao\src\4083_mit\test\in.txt
|
||||||
2020/04/06 周一 12:33:23.89
|
2020/06/13 ÖÜÁù 11:23:05.54
|
||||||
10
|
1
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 260 ms with return value 0
|
Process exited after 170 ms with return value 0
|
||||||
|
|
||||||
## z:\Chao\src\4083_mit\test\In1 (19).txt
|
## z:\Chao\src\4083_mit\test\In1 (19).txt
|
||||||
2020/04/06 周一 12:33:23.89
|
2020/06/13 ÖÜÁù 11:23:05.54
|
||||||
1
|
1
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 190 ms with return value 0
|
Process exited after 170 ms with return value 0
|
||||||
|
|
||||||
## z:\Chao\src\4083_mit\test\In2 (12).txt
|
## z:\Chao\src\4083_mit\test\In2 (12).txt
|
||||||
2020/04/06 周一 12:33:23.89
|
2020/06/13 ÖÜÁù 11:23:05.54
|
||||||
1
|
1
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 210 ms with return value 0
|
Process exited after 170 ms with return value 0
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
# 标题
|
||||||
|
|
||||||
|
* 内容
|
|
@ -0,0 +1 @@
|
||||||
|
#
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
bool ce[20001]={0};
|
||||||
|
int main(){
|
||||||
|
int n;
|
||||||
|
int a[101],ans=0;
|
||||||
|
cin>>n;
|
||||||
|
for(int i=1;i<=n;i++){
|
||||||
|
cin>>a[i];
|
||||||
|
ce[a[i]]=1;
|
||||||
|
}
|
||||||
|
for(int i=1;i<=n-1;i++){
|
||||||
|
for(int j=i+1;j<=n;j++){
|
||||||
|
int now=a[i]+a[j];
|
||||||
|
if(ce[now]==1){
|
||||||
|
ans++;
|
||||||
|
ce[now]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<ans;
|
||||||
|
return 0;
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
||||||
|
100
|
||||||
|
7855 581 4513 9204 9770 9321 1016 6839 2710 4343 9224 2006 863 7705 2087 3002 6409 4198 9950 7360 1296 3947 740 7049 1660 1726 540 9635 8055 6799 4978 5593 2465 5711 7953 2663 2771 8789 3865 7457 1363 3663 5823 723 1960 4886 6646 9259 8831 5910 1277 7031 5597 6316 4488 5097 8710 5936 531 1842 13 1877 8868 8622 3036 351 65 8508 9574 4420 3202 3681 5660 1878 408 8701 93 1424 3886 6286 6961 911 9343 8356 2536 1193 677 9502 534 7280 2161 163 2477 7429 552 5400 5196 6952 4923 5515
|
|
@ -0,0 +1,7 @@
|
||||||
|
## z:\Chao\src\Template\test\in.txt
|
||||||
|
2020/03/14 ÖÜÁù 11:41:28.68
|
||||||
|
Hello Easy C++ project!
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
Process exited after 200 ms with return value 0
|
||||||
|
|
Loading…
Reference in New Issue