# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1125943 | lam280407 | Jobs (BOI24_jobs) | C++20 | 46 ms | 4928 KiB |
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define inf32 0x3f3f3f3f
#define inf64 0x3f3f3f3f3f3f3f3f
#define el '\n'
#define bit(n, i) ((n >> i) & 1)
#define TASK "Jobs"
using namespace std;
const int base = 523;
const int blz = 350;
const int mode = 998244353;
const int N = 3e5 + 3;
template<typename T>
void maximize(T &a, T b){
if (a < b) a = b;
}
template<typename T>
void minimize(T &a, T b){
if (a > b) a = b;
}
int n, s;
struct query{
int cost, p;
bool operator < (const query &other) const{
return p < other.p;
}
}Q[N];
namespace sub23{
int mx = 0, pre[N];
void init(){
for (int i = 1; i <= n; ++i){
pre[i] = pre[i - 1] + Q[i].cost;
if (!Q[i].p) maximize(mx, Q[i].cost);
maximize(mx, pre[i]);
}
cout << mx;
}
}
void solve(){
cin >> n >> s;
bool ok = true;
for (int i = 1; i <= n; ++i){
int x, p;
cin >> x >> p;
Q[i] = {x, p};
if (p != i - 1 && p != 0) ok = false;
}
if (ok) sub23::init();
else cout << 6;
}
void file(){
if(fopen(TASK ".inp","r")){
freopen(TASK ".inp","r",stdin);
freopen(TASK ".out","w",stdout);
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
file();
solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |