Skip to content

Commit ad90589

Browse files
Augusto CalacaAugusto Calaca
authored andcommitted
Add more questions
1 parent 683cf56 commit ad90589

File tree

2 files changed

+52
-9
lines changed

2 files changed

+52
-9
lines changed

uri/uri1222.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <iostream>
2+
#include <algorithm>
3+
#include <cmath>
4+
#include <vector>
5+
#include <map>
6+
7+
#define f first
8+
#define s second
9+
#define pb push_back
10+
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
11+
using namespace std;
12+
13+
typedef long long ll;
14+
typedef unsigned long long ull;
15+
16+
int main() {
17+
FAST;
18+
19+
int n, l, c, sz, cfl, lfp, ans;
20+
string str;
21+
22+
while(cin >> n >> l >> c) {
23+
ans = cfl = 0;
24+
lfp = 1;
25+
for(int i = 0; i < n; i++) {
26+
cin >> str;
27+
sz = str.size();
28+
if(cfl + sz <= c) cfl += sz + 1;
29+
else {
30+
lfp++;
31+
cfl = sz + 1;
32+
}
33+
if(lfp == l) lfp = 0, ans++;
34+
}
35+
if(lfp > 0) ans++;
36+
cout << ans << "\n";
37+
}
38+
39+
return 0;
40+
}

uri/uri1228.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,28 @@ using namespace std;
1313
typedef long long ll;
1414
typedef unsigned long long ull;
1515

16-
int start[30], fini[30];
17-
int search(int n, int k) {
18-
for(int i = 0; i < n; i++)
19-
if(fini[i] == k) return i;
20-
}
16+
int start[30], fini[30], u[30];
2117

2218
int main() {
2319
FAST;
2420

2521
int n;
2622
while(cin >> n) {
2723
for(int i = 0; i < n; i++)
28-
cin >> v[i];
24+
cin >> start[i];
2925
for(int i = 0; i < n; i++)
3026
cin >> fini[i];
3127

32-
for(int i = 1; i < n; i++) {
33-
int f = find(n, start[i]);
34-
if(f < i) ans += (i - f);
28+
int ans = 0;
29+
for(int i = 0; i < n; i++) {
30+
for(int j = 0; j < n; j++)
31+
if(fini[j] == start[i]) {
32+
u[i] = j;
33+
break;
34+
}
35+
if(i < 1) continue;
36+
for(int j = 0; j < i; j++)
37+
if(u[j] > u[i]) ans++;
3538
}
3639

3740
cout << ans << "\n";

0 commit comments

Comments
 (0)