【題解】Codeforces 1321A. Contest for Robots

【題目敘述】http://codeforces.com/contest/1321/problem/A

#include <iostream>
using namespace std;
 
int n, a[105], b[105], c, d;
 
int main() {
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> b[i];
        if (a[i] == 0){
            if (b[i] == 1) d++;
        }
        else if (b[i] == 0) c++;
    }
    if (c == 0) cout << -1 << "\n";
    else cout << d/c + 1 << "\n";
}
分享本文 Share with friends