제출 #1023649

#제출 시각아이디문제언어결과실행 시간메모리
1023649vjudge1Knapsack (NOI18_knapsack)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std;// Hello world arsaoshe aneru nesi isods const int mod = 1e9+7; const char nl = '\n'; typedef long long ll; const int N = 1e5 + 5 ; #define ff first #define ss second void void_code () { ll s; cin >> s ; ll n; cin >> n; vector < pair < int , pair < int , int > > > vec ( n) ; for ( int i =0 ; i < n; i ++ ) { cin >> vec [ i ] . ff >> vec [ i ] . ss . ff >> vec [ i ] . ss . ss ; } ll ans = 0; sort ( vec . rbegin () , vec . rend () ) ; for ( int i = 0 ; i < n; i ++ ) { ll as = vec [ i ] . ss . ss * vec [ i ] . ss. ff ; ll cost = vec [ i ] . ss . ss * vec [ i ] . ff; //~ cout << i << " - " << as << " " << cost << nl; if ( vec [ i ] .ss . ff <= vec [ i - 1 ] . ss . ff ) while ( s - vec [ i ] . ss . ff >= 0 and vec [ i ] . ss . ss != 0 ) { vec [ i ] . ss . ss -- ; ans += vec [ i ] . ff ; s -= vec [ i ] . ss . ff ; } } //~ cout << "---" << nl; cout << ans ; } signed main() { ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); int t = 1; //test //~ cin >> t; while (t--) void_code (); return 0; }

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

knapsack.cpp: In function 'void void_code()':
knapsack.cpp:15:6: warning: unused variable 'as' [-Wunused-variable]
   15 |   ll as = vec [ i ] .  ss . ss * vec [ i ]  . ss. ff ;
      |      ^~
knapsack.cpp:16:6: warning: unused variable 'cost' [-Wunused-variable]
   16 |   ll cost = vec [ i ] . ss . ss * vec [ i ] . ff;
      |      ^~~~
#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...