Advertisement
Korotkodul

CF div3 D ПН WA тест 2

Aug 2nd, 2022
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int,int>
  11. #define vec vector
  12. using namespace std;
  13. using ll = long long;
  14. using ld = long double;
  15. using db = double;
  16. void cv(vector <int> &v){
  17.     for (auto x: v) cout<<x<<' ';
  18.     cout<<"\n";
  19. }
  20.  
  21. void cvl(vector <ll> &v){
  22.     for (auto x: v) cout<<x<<' ';
  23.     cout<<"\n";
  24. }
  25.  
  26.  
  27. void cvv(vector <vector <int> > &v){
  28.     for (auto x: v) cv(x);
  29.     cout<<"\n";
  30. }
  31.  
  32. void cvb(vector <bool> v){
  33.     for (bool x: v) cout<<x<<' ';
  34.     cout<<"\n";
  35. }
  36.  
  37. void cvs(vector <string>  v){
  38.     for (auto a: v){
  39.         cout<<a<<"\n";
  40.     }
  41. }
  42.  
  43. void cvp(vector <pii> a){
  44.     for (auto p: a){
  45.         cout<<p.first<<' '<<p.second<<"\n";
  46.     }
  47.     cout<<"\n";
  48. }
  49.  
  50. bool sh=0;
  51. int n;
  52. vector <int> a;
  53.  
  54. void slv(){
  55.     sort(a.begin(), a.end());
  56.     reverse(a.begin(), a.end());
  57.     //утв 0 - все уже равны
  58.     if (a[0] == a[n-1]){
  59.         cout<<"YES\n";
  60.         return;
  61.     }
  62.     bool r05=0, roth=0;
  63.     for (int i: a){
  64.         if (i%10 == 0 || i % 10 == 5){
  65.             r05=1;
  66.         }
  67.         else{
  68.             roth=1;
  69.         }
  70.         if (r05 && roth){
  71.             cout<<"NO\n";
  72.             return;
  73.         }
  74.     }
  75.     if (r05){
  76.         if (a[n-1] + a[n-1]%10 == a[0]){
  77.             cout<<"YES\n";
  78.             return;
  79.         }
  80.         else{
  81.             cout<<"NO\n";
  82.             return;
  83.         }
  84.     }
  85.  
  86.     //остальное
  87.     int r = a[0] % 10;
  88.     if (r == 3 || r == 7 || r == 9){
  89.         cout<<"NO\n";
  90.         return;
  91.     }
  92.     for (int i=0;i < n;++i){
  93.         while (a[i] % 10 != 2){
  94.             a[i] += a[i] % 10;
  95.         }
  96.     }
  97.     sort(a.begin(), a.end());
  98.     reverse(a.begin(), a.end());
  99.     bool can=1;
  100.     for (int i = 0; i < n;++i){
  101.         int d = a[0] - a[i];
  102.         if (d%20 != 0){
  103.             cout<<"NO\n";
  104.             return;
  105.         }
  106.     }
  107.     cout<<"YES\n";
  108. }
  109.  
  110.  
  111. int main()
  112. {
  113.     ios::sync_with_stdio(0);
  114.     cin.tie(0);
  115.     cout.tie(0);
  116.     int t;
  117.     if (!sh) cin>>t;
  118.     for (int go=0;go<t;++go){
  119.         cin>>n;
  120.         a.resize(n);
  121.         for (int &i: a) cin>>i;
  122.         slv();
  123.     }
  124. }
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement