# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091911 | idk__ | Bouquet (EGOI24_bouquet) | C++14 | 19 ms | 2784 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
pair<int, int>a[n];
bool flag = 1;
bool flag2 = 1;
int xx,yy;
for(int i = 0;i < n; i++){
int x, y; cin >> x >> y;
a[i] = {x, y};
if(!i)xx=y, yy=y;
if(x!=y or xx!=x)flag = 0;
if(y!=0)flag2 = 0;
}
if(flag){
int cnt = 0;
for(int i = 0;i < n;){
i+=xx+1;
cnt++;
}
cout << cnt << endl;
}
// 7
// 0 0 = 1
// 0 0 = 1
// 1 0
// 1 0
// 2 0
// 3 0
// 2 0
//last = 1, 2-1=1
else if(flag2){
int cnt = 0;
int check[n]={};
int last = 0;
for(int i = 0;i < n; i++){
auto [x, y] = a[i];
if(i-x-1 < 0)check[i]=1, cnt++;
else{
if(last < i-x)check[i]=1, cnt++;
}
if(check[i])last = i;
}
cout << cnt << endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |