File tree Expand file tree Collapse file tree 10 files changed +260
-65
lines changed
Expand file tree Collapse file tree 10 files changed +260
-65
lines changed Original file line number Diff line number Diff line change @@ -46,22 +46,5 @@ int main()
4646 cin >> tc;
4747 while (tc--)
4848 {
49- ll a, b;
50- cin >> a >> b;
51- string s;
52- cin >> s;
53- char arr[s.length ()];
54- ll zero = 0 , one = 0 ;
55- for (ll i = 0 ; i < n; i++)
56- {
57- arr[i] = s[i];
58- if (arr[i] == ' 0' )
59- zero++;
60- if (arr[i] == ' 1' )
61- one++;
62- }
63- for (ll i = 0 ; i < n / 2 ; i++)
64- {
65- }
6649 }
6750}
Original file line number Diff line number Diff line change @@ -18,8 +18,18 @@ using namespace std;
1818#define MP make_pair
1919#define FF first
2020#define SS second
21- #define max (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
22- #define min (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
2333#define FIO \
2434 ios_base::sync_with_stdio (false ); \
2535 cin.tie(NULL ); \
@@ -38,21 +48,20 @@ int main()
3848 {
3949 ll n;
4050 cin >> n;
41- vector<ll> v ;
42- while (n > 0 )
51+ ll i = 0 ;
52+ while (i < 20 )
4353 {
44- v.push_back (n % 10 );
45- n /= 10 ;
46- }
47- ll curr = v[v.size () - 1 ];
48- for (ll i = v.size () - 2 ; i >= 0 ; i--)
49- {
50- v[i] -= curr;
51- curr += v[i];
54+ i++;
55+ if (n % 11 == 0 )
56+ {
57+ break ;
58+ }
59+
60+ n -= 111 ;
5261 }
53- if (v[0 ] != 0 )
54- cout << " NO" << endl;
55- else
62+ if (n % 11 == 0 && n >= 0 )
5663 cout << " YES" << endl;
64+ else
65+ cout << " NO" << endl;
5766 }
5867}
Original file line number Diff line number Diff line change @@ -18,8 +18,18 @@ using namespace std;
1818#define MP make_pair
1919#define FF first
2020#define SS second
21- #define max (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
22- #define min (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
2333#define FIO \
2434 ios_base::sync_with_stdio (false ); \
2535 cin.tie(NULL ); \
@@ -32,14 +42,9 @@ int main()
3242 freopen (" input.txt" , " r" , stdin);
3343 freopen (" output.txt" , " w" , stdout);
3444#endif
35- ll n;
36- cin >> n;
37- ll arr[n];
38- ll sum = 0 ;
39- for (ll i = 0 ; i < n; i++)
45+ ll tc;
46+ cin >> tc;
47+ while (tc--)
4048 {
41- cin >> arr[i];
42- sum += arr[i];
4349 }
44-
4550}
Original file line number Diff line number Diff line change @@ -18,8 +18,18 @@ using namespace std;
1818#define MP make_pair
1919#define FF first
2020#define SS second
21- #define max (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
22- #define min (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
2333#define FIO \
2434 ios_base::sync_with_stdio (false ); \
2535 cin.tie(NULL ); \
Original file line number Diff line number Diff line change @@ -18,8 +18,18 @@ using namespace std;
1818#define MP make_pair
1919#define FF first
2020#define SS second
21- #define max (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
22- #define min (a, b ) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
2333#define FIO \
2434 ios_base::sync_with_stdio (false ); \
2535 cin.tie(NULL ); \
@@ -36,22 +46,5 @@ int main()
3646 cin >> tc;
3747 while (tc--)
3848 {
39- ll a, b;
40- cin >> a >> b;
41- string s;
42- cin >> s;
43- char arr[s.length ()];
44- ll zero = 0 , one = 0 ;
45- for (ll i = 0 ; i < n; i++)
46- {
47- arr[i] = s[i];
48- if (arr[i] == ' 0' )
49- zero++;
50- if (arr[i] == ' 1' )
51- one++;
52- }
53- for (ll i = 0 ; i < n / 2 ; i++)
54- {
55- }
5649 }
5750}
Original file line number Diff line number Diff line change 1+ /*
2+ Problem Link:
3+ #############################################
4+ Author: Siddharth Mishra
5+ GitHub: https://github.com/Hard-Coder05
6+ #############################################
7+ */
8+ #include < bits/stdc++.h>
9+ using namespace std ;
10+ #define endl " \n "
11+ #define MOD 1000000007
12+ #define INF INT_MAX
13+ #define vi vector<int >
14+ #define pii pair<int , int >
15+ #define ll long long
16+ #define ld long double
17+ #define PB push_back
18+ #define MP make_pair
19+ #define FF first
20+ #define SS second
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
33+ #define FIO \
34+ ios_base::sync_with_stdio (false ); \
35+ cin.tie(NULL ); \
36+ cout.tie(NULL );
37+
38+ int main ()
39+ {
40+ FIO;
41+ #ifndef ONLINE_JUDGE
42+ freopen (" input.txt" , " r" , stdin);
43+ freopen (" output.txt" , " w" , stdout);
44+ #endif
45+ ll tc;
46+ cin >> tc;
47+ while (tc--)
48+ {
49+ }
50+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Problem Link:
3+ #############################################
4+ Author: Siddharth Mishra
5+ GitHub: https://github.com/Hard-Coder05
6+ #############################################
7+ */
8+ #include < bits/stdc++.h>
9+ using namespace std ;
10+ #define endl " \n "
11+ #define MOD 1000000007
12+ #define INF INT_MAX
13+ #define vi vector<int >
14+ #define pii pair<int , int >
15+ #define ll long long
16+ #define ld long double
17+ #define PB push_back
18+ #define MP make_pair
19+ #define FF first
20+ #define SS second
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
33+ #define FIO \
34+ ios_base::sync_with_stdio (false ); \
35+ cin.tie(NULL ); \
36+ cout.tie(NULL );
37+
38+ int main ()
39+ {
40+ FIO;
41+ #ifndef ONLINE_JUDGE
42+ freopen (" input.txt" , " r" , stdin);
43+ freopen (" output.txt" , " w" , stdout);
44+ #endif
45+ ll n;
46+ cin >> n;
47+ multiset<ll> ms;
48+ ll sum = 0 ;
49+ for (ll i = 0 ; i < n; i++)
50+ {
51+ ll x;
52+ cin >> x;
53+ if (sum + x >= 0 )
54+ {
55+ ms.insert (x);
56+ sum += x;
57+ }
58+ else
59+ {
60+ ll bigneg = *(ms.begin ());
61+ if (bigneg <= x)
62+ {
63+ ms.erase (ms.begin ());
64+ sum -= bigneg;
65+ sum += x;
66+ ms.insert (x);
67+ }
68+ }
69+ }
70+ cout << ms.size () << endl;
71+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Problem Link:
3+ #############################################
4+ Author: Siddharth Mishra
5+ GitHub: https://github.com/Hard-Coder05
6+ #############################################
7+ */
8+ #include < bits/stdc++.h>
9+ using namespace std ;
10+ #define endl " \n "
11+ #define MOD 1000000007
12+ #define INF INT_MAX
13+ #define vi vector<int >
14+ #define pii pair<int , int >
15+ #define ll long long
16+ #define ld long double
17+ #define PB push_back
18+ #define MP make_pair
19+ #define FF first
20+ #define SS second
21+ #define max (a, b ) ( \
22+ { \
23+ __typeof__ (a) _a = (a); \
24+ __typeof__ (b) _b = (b); \
25+ _a > _b ? _a : _b; \
26+ })
27+ #define min (a, b ) ( \
28+ { \
29+ __typeof__ (a) _a = (a); \
30+ __typeof__ (b) _b = (b); \
31+ _a < _b ? _a : _b; \
32+ })
33+ #define FIO \
34+ ios_base::sync_with_stdio (false ); \
35+ cin.tie(NULL ); \
36+ cout.tie(NULL );
37+
38+ int main ()
39+ {
40+ FIO;
41+ #ifndef ONLINE_JUDGE
42+ freopen (" input.txt" , " r" , stdin);
43+ freopen (" output.txt" , " w" , stdout);
44+ #endif
45+ ll n;
46+ cin >> n;
47+ multiset<ll> ms;
48+ ll sum = 0 ;
49+ for (ll i = 0 ; i < n; i++)
50+ {
51+ ll x;
52+ cin >> x;
53+ if (sum + x >= 0 )
54+ {
55+ ms.insert (x);
56+ sum += x;
57+ }
58+ else
59+ {
60+ ll bigneg = *(ms.begin ());
61+ if (bigneg <= x)
62+ {
63+ ms.erase (ms.begin ());
64+ sum -= bigneg;
65+ sum += x;
66+ ms.insert (x);
67+ }
68+ }
69+ }
70+ // for (auto &i : ms)
71+ // cout << i << " ";
72+ // cout << endl;
73+ cout << ms.size () << endl;
74+ }
Original file line number Diff line number Diff line change 113
2233
33144
4- 121
4+ 1111
Original file line number Diff line number Diff line change 11YES
22YES
3- NO
3+ YES
You can’t perform that action at this time.
0 commit comments