QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#662063 | #5426. Drain the Water Tank | 1ockhart | WA | 0ms | 3804kb | C++20 | 792b | 2024-10-20 20:24:12 | 2024-10-20 20:24:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
void solve() {
int n;
cin >> n;
vector<pii> a;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
a.push_back({ x,y });
}
for (int i = 0; i < n; i++)
a.push_back(a[i]);
int ans = 0;
int f = 0;
int p = n;
for (int i = 1; i <= 2*n-1;i++) {
if (i == p + n)
break;
if (a[i - 1].first <= a[i].first) {
if (f && a[i - 1].second < a[i].second) {
f = 0, ans++;
p = min(p, i);
}
if (a[i - 1].second > a[i].second)
f = 1;
}
else
f = 0;
}
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
6 0 0 1 1 2 1 3 0 3 2 0 2
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
8 4 4 0 4 0 2 1 2 2 2 2 0 3 0 4 0
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
7 1 0 3 4 0 3 1 2 2 3 1 1 0 2
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3804kb
input:
6 0 0 2 0 1 1 4 1 5 0 3 4
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'