제출 #1115401

#제출 시각아이디문제언어결과실행 시간메모리
1115401EfeBabagilJobs (BOI24_jobs)C++14
0 / 100
2079 ms15956 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N=1e5+5; const int mod=1e9+7; int32_t main() { int n,s; cin>>n>>s; vector<pair<int,int>> jobs(n+1); vector<pair<int,int>> prof(n+1); jobs[0]={0,-1}; for(int i=1;i<n+1;i++) { int a,b; cin>>a>>b; b; jobs[i]={a,b}; } for(int i=1;i<n+1;i++) { vector<int> vis(n); pair<int,int> x=jobs[i]; vis[i]=1; int sum=0; int mn=0; int flag=1; int flag2=1; //3 2 while(x.second!=-1) { if(vis[x.second]){ flag=0; break; } vis[x.second]=1; x=jobs[x.second]; if(x.first>=0&&flag2){ prof[i].second=sum; flag2=0; } sum+=x.first; if(mn+x.first<0) mn+=x.first; else mn=0; } if(flag){ prof[i].first=-mn; prof[i].second+=jobs[i].first; } } sort(prof.begin(),prof.end()); int ans=0; for(int i=1;i<=n;i++) { if(prof[i].first<=s && prof[i].second>0) { ans+=prof[i].second; s+=prof[i].second; } } cout<<ans; return 0; } // 1-> 3 0 // 2-> -3 1 // 3-> -3 0 // 4-> 2 1 // 5-> 6 3 // 6-> -4 5

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int32_t main()':
Main.cpp:18:9: warning: statement has no effect [-Wunused-value]
   18 |         b;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...