File tree 4 files changed +136
-0
lines changed
4 files changed +136
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ int main () {
7
+ ios_base::sync_with_stdio (false );
8
+ cin.tie (0 ); cout.tie (0 );
9
+
10
+ string A, B, C;
11
+ cin >> A >> B >> C;
12
+ if (A[A.size ()-1 ] == B[0 ] && B[B.size ()-1 ] == C[0 ]) {
13
+ cout<< " YES" << endl;
14
+ } else {
15
+ cout << " NO" << endl;
16
+ }
17
+
18
+ return 0 ;
19
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ bool solve (int A, int B, int C) {
7
+ for (int i = 1 ; i <= B; ++i) {
8
+ if ((A * i) % B == C) return true ;
9
+ }
10
+ return false ;
11
+ }
12
+
13
+ int main () {
14
+ ios_base::sync_with_stdio (false );
15
+ cin.tie (0 ); cout.tie (0 );
16
+
17
+ int A, B, C;
18
+ cin >> A >> B >> C;
19
+ auto ans = solve (A, B, C) ? " YES" : " NO" ;
20
+ cout << ans << endl;
21
+
22
+ return 0 ;
23
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ int N, T;
7
+ vector<int > ts;
8
+
9
+ int solve () {
10
+ int X = 0 ;
11
+ int b = 0 , e = 0 ;
12
+ for (auto t : ts) {
13
+ if (e < t) {
14
+ X += (e - b);
15
+ b = t;
16
+ e = t + T;
17
+ } else {
18
+ e = t + T;
19
+ }
20
+ }
21
+ X += (e - b);
22
+ return X;
23
+ }
24
+
25
+ int main () {
26
+ ios_base::sync_with_stdio (false );
27
+ cin.tie (0 ); cout.tie (0 );
28
+
29
+ cin >> N >> T;
30
+ ts.assign (N, 0 );
31
+ for (int i = 0 ; i < N; ++i) {
32
+ cin >> ts[i];
33
+ }
34
+ cout << solve () << endl;
35
+
36
+ return 0 ;
37
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ int N, W;
7
+ vector<int > wss, vss;
8
+
9
+ int solve () {
10
+ vector<deque<int >> v (4 );
11
+
12
+ v[0 ].push_back (vss[0 ]);
13
+ for (int i = 1 ; i < N; ++i) {
14
+ int dw = wss[i] - wss[0 ];
15
+ assert (dw >= 0 && dw <= 3 );
16
+ v[dw].push_back (vss[i]);
17
+ }
18
+
19
+ for (int i = 0 ; i < 4 ; ++i) {
20
+ sort (v[i].begin (), v[i].end ());
21
+ reverse (v[i].begin (), v[i].end ());
22
+ v[i].push_front (0 );
23
+ for (int j = 1 ; j < v[i].size (); ++j) {
24
+ v[i][j] += v[i][j-1 ];
25
+ }
26
+ }
27
+
28
+ int ans = 0 ;
29
+ for (int i = 0 ; i < v[0 ].size (); ++i) {
30
+ for (int j = 0 ; j < v[1 ].size (); ++j) {
31
+ for (int k = 0 ; k < v[2 ].size (); ++k) {
32
+ for (int l = 0 ; l < v[3 ].size (); ++l) {
33
+ ll ww = ll (wss[0 ])*i + ll (wss[0 ]+1 )*j + ll (wss[0 ]+2 )*k + ll (wss[0 ]+3 )*l;
34
+ int vv = v[0 ][i] + v[1 ][j] + v[2 ][k] + v[3 ][l];
35
+ if (ww > W) continue ;
36
+ ans = max (ans, vv);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ return ans;
42
+ }
43
+
44
+ int main () {
45
+ ios_base::sync_with_stdio (false );
46
+ cin.tie (0 ); cout.tie (0 );
47
+
48
+ cin >> N >> W;
49
+ wss.assign (N, 0 );
50
+ vss.assign (N, 0 );
51
+ for (int i = 0 ; i < N; ++i) {
52
+ cin >> wss[i] >> vss[i];
53
+ }
54
+ cout << solve () << endl;
55
+
56
+ return 0 ;
57
+ }
You can’t perform that action at this time.
0 commit comments