Submission #52171

# Submission time Handle Problem Language Result Execution time Memory
52171 2018-06-24T13:03:48 Z `مرحبا بالعالم`(#1336) Fortune Telling 2 (JOI14_fortune_telling2) C++11
4 / 100
2000 ms 1632 KB
#include <bits/stdc++.h>
#define dbgv(v) {for(auto x:v)cout<<x<<' ';cout<<'\n';}
#define entire(v) v.begin(),v.end()
typedef long long ll;
using namespace std;
void OJize(){
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    #ifdef jh
    freopen("input.txt", "r", stdin);
    #endif
}

int main(){OJize();
    int n, k; cin>>n>>k;
    vector<bool> flipped(n);
    vector<int> F(n), B(n);
    for(int i=0; i<n; i++) cin>>F[i]>>B[i];
    for(int i=0; i<k; i++){
        int x; cin>>x;
        for(int j=0; j<n; j++){
            if(flipped[j] && B[j] <= x) flipped[j] = false;
            else if(!flipped[j] && F[j] <= x) flipped[j] = true;
        }
    }
    
    ll ans = 0;
    for(int i=0; i<n; i++) ans+= flipped[i]? B[i] : F[i];
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 14 ms 576 KB Output is correct
4 Correct 12 ms 620 KB Output is correct
5 Correct 12 ms 620 KB Output is correct
6 Correct 12 ms 620 KB Output is correct
7 Correct 12 ms 700 KB Output is correct
8 Correct 6 ms 736 KB Output is correct
9 Correct 4 ms 736 KB Output is correct
10 Correct 5 ms 736 KB Output is correct
11 Correct 12 ms 736 KB Output is correct
12 Correct 16 ms 844 KB Output is correct
13 Correct 12 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 14 ms 576 KB Output is correct
4 Correct 12 ms 620 KB Output is correct
5 Correct 12 ms 620 KB Output is correct
6 Correct 12 ms 620 KB Output is correct
7 Correct 12 ms 700 KB Output is correct
8 Correct 6 ms 736 KB Output is correct
9 Correct 4 ms 736 KB Output is correct
10 Correct 5 ms 736 KB Output is correct
11 Correct 12 ms 736 KB Output is correct
12 Correct 16 ms 844 KB Output is correct
13 Correct 12 ms 844 KB Output is correct
14 Correct 981 ms 1080 KB Output is correct
15 Execution timed out 2058 ms 1632 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 14 ms 576 KB Output is correct
4 Correct 12 ms 620 KB Output is correct
5 Correct 12 ms 620 KB Output is correct
6 Correct 12 ms 620 KB Output is correct
7 Correct 12 ms 700 KB Output is correct
8 Correct 6 ms 736 KB Output is correct
9 Correct 4 ms 736 KB Output is correct
10 Correct 5 ms 736 KB Output is correct
11 Correct 12 ms 736 KB Output is correct
12 Correct 16 ms 844 KB Output is correct
13 Correct 12 ms 844 KB Output is correct
14 Correct 981 ms 1080 KB Output is correct
15 Execution timed out 2058 ms 1632 KB Time limit exceeded
16 Halted 0 ms 0 KB -