Submission #48391

# Submission time Handle Problem Language Result Execution time Memory
48391 2018-05-12T16:41:33 Z maksim_gaponov Fortune Telling 2 (JOI14_fortune_telling2) C++14
4 / 100
7 ms 1540 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

void openFiles() {
#ifdef KEK
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif
}

void IOoptimize() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

const int MAXN = 1e3 + 10;
const int MAXK = 1e3 + 10;
int a[MAXN][2];
int t[MAXK];
int active_side[MAXN];

int main() {
    openFiles();
    IOoptimize();
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1];
    }
    for (int i = 0; i < k; i++) {
        cin >> t[i];
    }
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < n; j++) {
            if (a[j][active_side[j]] <= t[i]) {
                active_side[j] = 1 - active_side[j];
            }
        }
    }
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i][active_side[i]];
    }
    cout << sum;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 4 ms 496 KB Output is correct
3 Correct 7 ms 640 KB Output is correct
4 Correct 7 ms 756 KB Output is correct
5 Correct 7 ms 756 KB Output is correct
6 Correct 7 ms 780 KB Output is correct
7 Correct 7 ms 940 KB Output is correct
8 Correct 4 ms 940 KB Output is correct
9 Correct 3 ms 1112 KB Output is correct
10 Correct 3 ms 1116 KB Output is correct
11 Correct 7 ms 1132 KB Output is correct
12 Correct 6 ms 1140 KB Output is correct
13 Correct 6 ms 1140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1412 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1540 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -