题解:P11654 「FAOI-R5」becoder

· · 题解

#include <bits/stdc++.h>
using namespace std;
#define RETURN return 0
int main() {
    int n, L, R;
    cin >> n >> L >> R;// 声明数组T和M,分别存储每个测试用例的时间限制和内存限制
    int T[n], M[n];
    int t[n], m[n];
    for (int i = 0; i < n; ++i) cin >> T[i] >> M[i];// 循环读取每个测试用例的实际运行时间和实际使用内存
    for (int i = 0; i < n; ++i) cin >> t[i] >> m[i];// 循环处理每个测试用例
    for (int i = 0; i < n; ++i) {
        int f = i + 1;
        if (f >= L && f <= R) {
            cout << "System Error" << endl;
            continue;
        }
        if (M[i] > m[i]) {
            cout << "Memory Limit Exceeded" << endl;
            continue;
        }// 计算当前测试用例的时间限制的一半
        int time = T[i] / 2;
        if (time > t[i]) {
            cout << "Time Limit Exceeded" << endl;
            continue;
        }
        cout << "Accepted" << endl;
    }
    RETURN;
}

注:

   for (int i = 0; i < n; ++i) cin >> T[i] >> M[i];
   for (int i = 0; i < n; ++i) cin >> t[i] >> m[i];