Submission #1102337

#TimeUsernameProblemLanguageResultExecution timeMemory
1102337TVSownTopical (NOI23_topical)C++17
100 / 100
412 ms148648 KiB
///*** Sown_Vipro ***/// /// ->GIAI BA QUOC GIA<- /// #include<bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") #define F first #define S second #define pb push_back #define pi pair<int, int> #define pii pair<int, pair<int, int> > #define FOR(i, a, b) for(int i = a; i <= b; ++i) #define REP(i, a, b) for(int i = a; i >= b; --i) #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin); #define out(name) if(fopen(name, "w")) freopen(name, "w", stdout); #define szz(s) int(s.size()) const int N = 1e6 + 5, MAX = 1e6, oo = 1e9 + 5, MOD = 1e9 + 7; int n, k, res; int skill[N], d[N]; vector<pi> e[N]; vector<vector<int> > r, u; queue<int> q; void solve(){ cin >> n >> k; r = vector<vector<int> > (n + 1, vector<int> (k + 1, 0)); u = r; FOR(i, 1, n){ FOR(j, 1, k){ cin >> r[i][j]; e[j].pb({r[i][j], i}); } d[i] = k; } FOR(j, 1, k) sort(e[j].begin(), e[j].end(), greater<pi>()); FOR(i, 1, n){ FOR(j, 1, k) cin >> u[i][j]; } FOR(j, 1, k){ while(szz(e[j]) && e[j].back().F <= skill[j]){ --d[e[j].back().S]; if(!d[e[j].back().S]) q.push(e[j].back().S); e[j].pop_back(); } } while(q.size()){ int i = q.front(); q.pop(); ++res; FOR(j, 1, k){ skill[j] += u[i][j]; while(szz(e[j]) && e[j].back().F <= skill[j]){ --d[e[j].back().S]; // cout << e[j].back().S << " " << d[e[j].back().S] << "\n"; if(!d[e[j].back().S]) q.push(e[j].back().S); e[j].pop_back(); } } } cout << res; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); inp("in.txt"); int t = 1; // cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:16:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:70:5: note: in expansion of macro 'inp'
   70 |     inp("in.txt");
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...