Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ChuvSU yandex.contest 20!8
- //Matvey&Volodya 21-18
- //Compiler == GNU c++11 4.9
- //1
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, sum=0;
- cin >> n;
- int a[n];
- for (int i=0;i<n;i++)
- cin >> a[i];
- for (int i=0;i<n;i++)
- sum+=a[i];
- cout<<sum;
- }
- //2
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,temp=0,len=0,m=0,max_len=0;
- cin >> n;
- int a[n];
- for (int i=0; i<n; i++)
- cin >> a[i];
- for (int i=1; i<n; i++)
- {
- if(a[i]<a[i-1])
- len++;
- else{
- if(len>max_len)
- {
- max_len=len;
- m=temp;
- }
- len=0;
- temp=i;
- }
- }
- if(max_len>len)
- {
- len=max_len;
- temp=m;
- }
- max_len=0;
- for(int i=temp; i<=temp+len; i++) max_len++;
- cout << max_len;
- }
- //3
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,temp=0,len=0,m=0,max_len=0;
- cin >> n;
- int a[n];
- for (int i=0; i<n; i++)
- cin >> a[i];
- for (int i=1; i<n; i++)
- {
- if(a[i]>a[i-1])
- len++;
- else{
- if(len>max_len)
- {
- max_len=len;
- m=temp;
- }
- len=0;
- temp=i;
- }
- }
- if(max_len>len)
- {
- len=max_len;
- temp=m;
- }
- max_len=0;
- for(int i=temp; i<=temp+len; i++) max_len++;
- cout << max_len;
- }
- //5
- #include <iostream>
- using namespace std;
- int main()
- {
- int N;
- cin >> N;
- int a[N];
- for (int i=0;i<N;i++)
- cin >> a[i];
- for (int i=0;i<N;i++)
- if ((a[i]%2)!=0) cout << a[i] << " ";
- for (int i = 0; i < N; i++)
- if ((a[i]%2)==0) cout << a[i] << " ";
- return 0;
- }
- //6
- #include <iostream>
- using namespace std;
- int main()
- {
- int N,i;
- cin >> N;
- int a[N];
- for (int i=0;i<N;i++)
- cin >> a[i];
- for (int i=0;i<N;i++){
- if ((a[i]%2)==0) cout << a[i] << " ";}
- for (int i = 0; i < N; i++){
- if ((a[i]%2)!=0) cout << a[i] << " ";}
- return 0;
- }
- //7
- #include <iostream>
- using namespace std;
- int main()
- {
- float AvgSum,Sum=0,Count=0;
- int N;
- cin >> N;
- int a[N];
- for (int i = 0; i < N; i++)
- cin >> a[i];
- for (int i = 0; i < N; i++)
- {
- if (a[i]>0)
- {
- Sum+=a[i];
- Count++;
- }
- }
- if (Count==0)
- AvgSum=0;
- else AvgSum=Sum/Count;
- for (int i = 0; i < N; i++)
- {
- if (a[i]<=AvgSum)
- cout << a[i] << " ";
- }
- }
- //8
- #include <iostream>
- using namespace std;
- int main()
- {
- int N,Count=0;
- int m;
- cin >> N;
- int a[N];
- for (int i=0;i<N;i++)
- cin >> a[i];
- cin >> m;
- for (int i=0;i<N;i++)
- if (a[i]==m*m) {cout << a[i] << " "; Count++;}
- if (Count==0) cout << "NO";
- return 0;
- }
- //9
- #include <iostream>
- using namespace std;
- int main()
- {
- int N;
- cin >> N;
- int a[N];
- for (int i = 0; i < N; ++i)
- cin >> a[i];
- for (int i = 0; i < N; ++i)
- {
- if (a[i]!=0) cout << a[i] << " ";
- }
- return 0;
- }
- //10
- #include <iostream>
- using namespace std;
- int main()
- {
- int N;
- cin >> N;
- int a[N];
- for (int i = 0; i < N; ++i)
- cin >> a[i];
- for (int i = N; i >= 1; --i)
- for (int j = 0; j < i; ++j)
- {
- if(a[j]==0)
- {
- int temp = a[j];
- a[j] = a[j-1];
- a[j-1] = temp;
- }
- }
- for (int i = 0; i < N; ++i)
- cout << a[i] << " ";
- return 0;
- }
- //11
- #include <iostream>
- using namespace std;
- int main()
- {
- int N,K,temp;
- cin >> N;
- long long a[N];
- cin >> K;
- long long b[K];
- for (int i=0;i<N;++i)
- cin >> a[i];
- for (int i=0;i<K;++i)
- cin >> b[i];
- for (int i=0;i<K;++i)
- {
- temp=0;
- for (int j=0;j<N;++j)
- {
- if (b[i]==a[j]) ++temp;
- }
- if (temp==0) cout << "NO ";
- else cout << "YES ";
- }
- return 0;
- }
- //12 (!!!!!!HELLO ITS ME!!!!!!!)
- #include <iostream>
- using namespace std;
- void quickSort(unsigned int *numbers, unsigned int left, unsigned int right)
- {
- unsigned int pivot;
- unsigned int l_hold = left;
- unsigned int r_hold = right;
- pivot = numbers[left];
- while (left < right)
- {
- while ((numbers[right] >= pivot) && (left < right))
- right--;
- if (left != right)
- {
- numbers[left] = numbers[right];
- left++;
- }
- while ((numbers[left] <= pivot) && (left < right))
- left++;
- if (left != right)
- {
- numbers[right] = numbers[left];
- right--;
- }
- }
- numbers[left] = pivot;
- pivot = left;
- left = l_hold;
- right = r_hold;
- if (left < pivot)
- quickSort(numbers, left, pivot - 1);
- if (right > pivot)
- quickSort(numbers, pivot + 1, right);
- }
- int SearchBinary(unsigned int arr[], unsigned int left, unsigned int right, unsigned int key)
- {
- unsigned int midd = 0;
- while (1)
- {
- midd = (left + right) / 2;
- if (key < arr[midd])
- right = midd - 1;
- else if (key > arr[midd])
- left = midd + 1;
- else
- return 1;
- if (left > right)
- return 0;
- }
- }
- int main()
- {
- unsigned int N,K,MAX,MIN;
- unsigned int a[200000];
- bool n[200000];
- cin>>N;
- cin>>K;
- for ( unsigned int i = 0 ; i < N ; i++)
- {
- cin>>a[i];
- }
- quickSort(a,0,N-1);
- MIN = a[0];
- MAX = a[N-1];
- for ( unsigned int i = 0 ; i < K ; i++)
- {
- unsigned int b;
- cin>>b;
- n[i] = false;
- if ((b<MIN)||(b>MAX)) continue;
- n[i] = SearchBinary(a,0,N-1,b);
- }
- for ( unsigned int i = 0 ; i < K ; i++)
- {
- if (n[i]) cout<<"YES ";
- else cout<<"NO ";
- }
- return 0;
- }
- //13
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,val=1;
- cin >> n;
- int a[n],d[n];
- for (int i = 0; i < n; i++)
- cin >> a[i];
- d[0] = a[0];
- for (int i = 0; i < n; i++)
- {
- bool r=true;
- for (int j = 0; j < val; j++)
- if (a[i]==d[j]) {r=false; break;}
- if (r) {d[val] = a[i]; val++;}
- }
- for (int i = 0; i < val; i++)
- cout << d[i] << " ";
- return 0;
- }
- //15
- #include <iostream>
- using namespace std;
- int main()
- {
- int N,temp=0;
- cin >> N;
- int arr[N][N];
- for (int i=0;i<N;i++)
- {
- for (int j=0;j<N;j++)
- {
- if(i==j)
- {
- arr[i][j]=0;
- for (int k=0;k<N-i;k++)
- {
- arr[i+k][j]=k;
- }
- for (int k=i;k>=0;k--)
- {
- arr[k][j]=temp;
- temp++;
- }
- temp=0;
- }
- }
- }
- for (int i=0;i<N;i++){
- for (int j=0;j<N;j++){
- cout << arr[i][j] << " ";}
- cout << endl;}
- }
- //16
- #include <iostream>
- using namespace std;
- int main()
- {
- int N;
- cin>>N;
- int a[N];
- for (int i=0;i<N;i++)
- cin>>a[i];
- for (int i=0;i<N;i++)
- if (a[i]!=0) cout << a[i] << " ";
- for (int i=0;i<N;i++)
- if (a[i]==0) cout << a[i] << " ";
- return 0;
- }
- //Qotlets ))))))))) (na samom dele grustno)
- #include <iostream>
- using namespace std;
- int main()
- {int k, m,n, min;
- cin>>k>>m>>n;
- if (n<=k) {min=2*m; cout<<min;}
- else if (n*2%k==0) {min=m*(n*2/k); cout<<min;}
- else {min=m*(1+(n*2/k)); cout<<min;};
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement