QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#823893 | #9832. If I Could Turn Back Time | ziyistudy# | WA | 0ms | 3664kb | C++14 | 1.0kb | 2024-12-21 10:36:04 | 2024-12-21 10:36:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll MOD=1e9+7;
// head
const int N=1e5+10;
struct node
{
int a,b;
}a[N];
signed main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t; cin>>t;
while (t--) {
int n;cin>>n;
for(int i=1;i<=n;++i) cin>>a[i].a;
for(int i=1;i<=n;++i) cin>>a[i].b;
bool f=false;
int k=0;
for(int i=1;i<=n;++i) {
if(a[k].a<a[i].a) k=i;
if(a[i].b<a[i].a) {
cout<<"-1\n";
f=true;
break;
}
}
if(f) continue;
f=false;
for(int i=1;i<=n;++i) {
if(a[i].a<a[k].a&&a[i].b>a[i].b) {
f=true;
cout<<"-1\n";
break;
}
}
if(f) continue;
int ans=0;
for (int i=1;i<=n;++i) {
ans=max(ans,a[i].b-a[i].a);
}
cout<<ans<<'\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
input:
4 4 3 2 4 2 5 3 6 2 1 10 100000 5 1 2 3 4 5 1 2 3 4 5 3 1 4 6 4 1 8
output:
2 99990 0 -1
result:
ok 4 number(s): "2 99990 0 -1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
10 1 1 2 2 2 7 2 7 1 6 8 1 1 1 1 3 8 2 4 4 9 7 4 5 5 5 5 8 6 6 6 2 3 3 10 3 2 6 1 8 2 4 4 6 8 9 4 7 9 10
output:
1 0 2 0 5 5 3 7 2 1
result:
ok 10 numbers
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3624kb
input:
100 1 4 9 2 57 42 67 52 2 9 53 13 68 1 5 10 1 11 41 1 4 8 1 7 16 5 1 12 66 2 14 33 21 83 11 29 1 20 22 2 29 67 59 98 4 1 12 85 1 26 16 98 5 1 4 47 5 8 8 37 40 58 11 31 54 66 89 2 22 12 75 63 1 10 10 1 34 37 7 7 16 21 62 3 16 1 9 46 55 96 4 44 2 1 4 24 4 2 1 23 18 29 28 82 68 4 73 77 66 6 80 84 72 8 ...
output:
5 10 15 5 30 4 9 32 2 31 25 43 31 53 0 3 34 20 59 7 46 34 50 33 14 51 20 47 3 90 23 19 0 35 13 17 51 26 84 43 16 85 6 32 28 19 24 3 36 39 45 5 13 9 10 22 30 33 13 26 9 42 30 17 45 26 68 32 8 11 6 13 23 18 68 3 51 59 27 20 3 55 38 4 14 92 10 7 18 59 11 51 55 3 85 42 14 39 28 7
result:
wrong answer 8th numbers differ - expected: '-1', found: '32'