QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#325965 | #5592. Family Visits | anpans# | WA | 0ms | 3580kb | C++14 | 849b | 2024-02-12 06:12:26 | 2024-02-12 06:12:27 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
int n, d;
int m[1000], c[1000];
int main() {
cin >> n >> d;
int pointer = 0;
while (pointer < n) {
cin >> m[pointer] >> c[pointer];
pointer++;
}
pointer = 0;
int ret = 0, curr = 0, visit;
while (pointer++ < d) {
set<int> s;
int mess = 0;
cin >> visit;
while (visit - 1 >= curr) {
s.insert(c[curr]);
mess += m[curr++];
}
while (s.size() > 0) {
mess -= *(s.rbegin());
ret++;
if (mess <= 0) break;
}
if (mess > 0) {
cout << -1 << endl;
return 0;
}
}
cout << ret << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3492kb
input:
6 2 1 2 2 1 1 4 3 2 3 6 2 3 3 6
output:
3
result:
ok single line: '3'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3580kb
input:
10 5 12 10 0 2 7 1 1 8 3 4 3 4 2 3 1 2 10 1 7 5 2 4 5 6 8
output:
6
result:
wrong answer 1st lines differ - expected: '7', found: '6'