Submission #1259437

#TimeUsernameProblemLanguageResultExecution timeMemory
1259437phtungLasers (NOI19_lasers)C++20
10 / 100
22 ms16992 KiB
#include <bits/stdc++.h>

using namespace std;

#define name "IO"
#define int long long 

const int inf = 1e18 + 7; 
const int maxn = 5e5 + 5; 
int L, R; 
vector<int> row[maxn]; 

void sub2()
{
    int res = 0; 
    for(int i = 1; i <= R; i++)
    {
        int l = row[i][0]; 
        if(l <= L / 2) continue; 

        int len = l - (L / 2); 
        if(L % 2) 
        {
            int new_val = len * 2ll - 1ll; 
            res = max(res, new_val); 
        } 
        else {
            int new_val = len * 2ll; 
            res = max(res, new_val); 
        }
    }

    cout << res << "\n"; 
}

void solve()
{
    cin >> L >> R;
    int mxX = 0; 

    for(int i = 1; i <= R; i++)
    {
        int x; cin >> x; 
        mxX = max(mxX, x); 
        for(int i = 1; i <= x; i++)
        {
            int len;
            cin >> len ;
            row[i].push_back(len); 
        }
    }   

    if(mxX == 1) sub2(); 

    


}

signed main()
{
    if (fopen (name".INP", "r"))
    {
        freopen (name".INP", "r", stdin);
        freopen (name".OUT", "w", stdout);
    }

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    clock_t start = clock(); 

    int t = 1;

    while(t--) solve(); 

    std::cerr << "Time: " << clock() - start << "ms\n";

    return 0; 

}

Compilation message (stderr)

lasers.cpp: In function 'int main()':
lasers.cpp:64:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen (name".INP", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
lasers.cpp:65:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen (name".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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...