제출 #1102404

#제출 시각아이디문제언어결과실행 시간메모리
1102404LTTrungCHLTopical (NOI23_topical)C++17
100 / 100
303 ms92136 KiB
///***LTT***/// /// ->NHAT QUOC GIA<- /// #include<bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") //#define int long long #define endl "\n" #define F first #define S second #define pb push_back using namespace std; vector <int> lg2; //void MAKE_LOG_ARR(int n){ // lg2.resize(n + 3); // for (int i = 1;i <= n;++i){ // lg2[i] = __lg(i); // } //} const long long oo = 1e9+7; const int N = 1e6 + 3; int n, k; vector <pair <int ,int>> in[N]; vector <int> a[N]; long long cur[N]; int cnt[N]; void solve(){ cin >> n >> k; for (int i = 1;i <= n;++i){ for (int j = 1;j <= k;++j){ int v; cin >> v; in[j].pb({v, i}); } } for (int i = 1;i <= n;++i){ a[i].pb(0); for (int j = 1;j <= k;++j){ int tmp; cin >> tmp; a[i].pb(tmp); } } for (int i = 1;i <= k;++i){ sort(in[i].begin(), in[i].end()); reverse(in[i].begin(), in[i].end()); } int gain = 0; while (1){ bool found = false; for (int i = 1;i <= k;++i){ while (!in[i].empty() and in[i].back().F <= cur[i]){ ++cnt[in[i].back().S]; if (cnt[in[i].back().S] == k){ found = true; for (int j = 1;j <= k;++j){ cur[j] += a[in[i].back().S][j]; cur[j] = min(cur[j], oo); } ++gain; } in[i].pop_back(); } } if (!found) break; } cout << gain; return; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); if (fopen("ltt.inp", "r")){ freopen("ltt.inp", "r", stdin); freopen("ltt.out", "w", stdout); } // int t; // cin >> t; // while(t--){ solve(); // } return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen("ltt.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         freopen("ltt.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...