Submission #1102326

# Submission time Handle Problem Language Result Execution time Memory
1102326 2024-10-18T02:29:00 Z huyngodzz Topical (NOI23_topical) C++14
61 / 100
1000 ms 143688 KB
    ///huynhocute123///
#include<bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define pii pair<int,int>
#define piii pair<int,pair<int,int>>
#define pb push_back
#define pi M_PI
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = b; i >= a; --i)
#define ALL(v) v.begin(),v.end()
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
//random_device rd;
//mt19937 rng(rd());
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
//#define int long long
const int maxN = 1e6 + 9 ;
const int  modd = 1e9 + 7;
const int base = 2309;
const int MAX = 1e9+9;
void minimize(int &u, int v){
    if(v < u) u = v;
}
void maximize(int &u, int v){
    if(v > u) u = v;
}
int n, k, t, m, res;
vector<vector<int>> a, b;
pii A[maxN];
int l, r;
bool vis[maxN];
vector<int> e[maxN];
long long sum[maxN];
void sub1(){
    for(int i= 1;i <= n ;i++){
        for(int j= 1;j <= m ;j++)cin >> a[i][j];
    }
    for(int i =1;i <= n ;i++){
        for(int j = 1;j <=m ;j++)cin >> b[i][j];
    }
    int res = 1;
    for(int j= 1;j <= m ;j++){
        if(a[1][j] != 0)res =0;
    }
    cout << res;
}
void sub2(){
    for(int i= 1;i <= n ;i++){
        for(int j= 1;j <= m ;j++)cin >> a[i][j];
    }
    for(int i =1;i <= n ;i++){
        for(int j = 1;j <=m ;j++)cin >> b[i][j];
    }
    set<int>st;
    for(int i =1;i <= n ;i++)st.insert(i);
    while(res <= n){
            vector<int> pass;
            for(auto i : st){
                int ok =1;
                for(int j=1 ; j <=m ;j++){
                    if(a[i][j] > sum[j]){
                        ok= 0;
                        break;
                    }
                }
                if(!ok)continue;
                for(int j=1;j <= m ;j++){
                    sum[j] += b[i][j];
                }
                res++;
                pass.pb(i);
            }
            if(pass.empty())break;
            for(auto x : pass)st.erase(x);
    }
    cout << res;
}
void sub3(){
    for(int i =1;i <= n ;i++)cin >> A[i].F;
    for(int i =1;i <= n ;i++)cin >> A[i].S;
    sort(A +1, A +1 + n);
    long long cur =0;
    for(int i=1; i <= n ;i++){
        if(cur >= A[i].F){
            cur+= A[i].S;
            res++;
        }else break;
    }
    cout << res;
}
void solve(){
    cin >>  n >> m;
    a = vector<vector<int>>  (n + 5, vector<int>(m + 5) );
    b= vector<vector<int>>  (n + 5, vector<int>(m + 5) );
    if(n==1){
        sub1();
        return;
    }
    if(m==1){
        sub3();
        return;
    }
    sub2();



}
signed main(){
//    freopen("name.inp","r",stdin);
//    freopen("name.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    inp("task.inp");
    t = 1;
   // cin >> t;
    while( t-- )solve();

}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:13:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:117:5: note: in expansion of macro 'inp'
  117 |     inp("task.inp");
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 26960 KB Output is correct
2 Correct 5 ms 26960 KB Output is correct
3 Correct 6 ms 27472 KB Output is correct
4 Correct 127 ms 78028 KB Output is correct
5 Correct 118 ms 77836 KB Output is correct
6 Correct 122 ms 77836 KB Output is correct
7 Correct 103 ms 77836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 26960 KB Output is correct
2 Correct 6 ms 27132 KB Output is correct
3 Correct 5 ms 26960 KB Output is correct
4 Correct 5 ms 26960 KB Output is correct
5 Correct 5 ms 26960 KB Output is correct
6 Correct 5 ms 26960 KB Output is correct
7 Correct 6 ms 27088 KB Output is correct
8 Correct 6 ms 27216 KB Output is correct
9 Correct 6 ms 27216 KB Output is correct
10 Correct 6 ms 27216 KB Output is correct
11 Correct 6 ms 27024 KB Output is correct
12 Correct 6 ms 27216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 26960 KB Output is correct
2 Correct 6 ms 26960 KB Output is correct
3 Correct 7 ms 28240 KB Output is correct
4 Correct 32 ms 40016 KB Output is correct
5 Correct 32 ms 40032 KB Output is correct
6 Correct 281 ms 143604 KB Output is correct
7 Correct 274 ms 143616 KB Output is correct
8 Correct 279 ms 143688 KB Output is correct
9 Correct 273 ms 143688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 26960 KB Output is correct
2 Correct 5 ms 26960 KB Output is correct
3 Correct 6 ms 27472 KB Output is correct
4 Correct 127 ms 78028 KB Output is correct
5 Correct 118 ms 77836 KB Output is correct
6 Correct 122 ms 77836 KB Output is correct
7 Correct 103 ms 77836 KB Output is correct
8 Correct 5 ms 26960 KB Output is correct
9 Correct 6 ms 27132 KB Output is correct
10 Correct 5 ms 26960 KB Output is correct
11 Correct 5 ms 26960 KB Output is correct
12 Correct 5 ms 26960 KB Output is correct
13 Correct 5 ms 26960 KB Output is correct
14 Correct 6 ms 27088 KB Output is correct
15 Correct 6 ms 27216 KB Output is correct
16 Correct 6 ms 27216 KB Output is correct
17 Correct 6 ms 27216 KB Output is correct
18 Correct 6 ms 27024 KB Output is correct
19 Correct 6 ms 27216 KB Output is correct
20 Correct 4 ms 26960 KB Output is correct
21 Correct 6 ms 26960 KB Output is correct
22 Correct 7 ms 28240 KB Output is correct
23 Correct 32 ms 40016 KB Output is correct
24 Correct 32 ms 40032 KB Output is correct
25 Correct 281 ms 143604 KB Output is correct
26 Correct 274 ms 143616 KB Output is correct
27 Correct 279 ms 143688 KB Output is correct
28 Correct 273 ms 143688 KB Output is correct
29 Correct 148 ms 35576 KB Output is correct
30 Correct 149 ms 35144 KB Output is correct
31 Execution timed out 1077 ms 52040 KB Time limit exceeded
32 Halted 0 ms 0 KB -