Submission #538363

# Submission time Handle Problem Language Result Execution time Memory
538363 2022-03-16T16:24:19 Z kabika Snail (NOI18_snail) C++17
25 / 100
1000 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll h;
	int n;
	cin >> h >> n;
	vector<ll> p(n);
	vector<ll> ps(n);
	ll hr = 0;
	int day = 0, phs = 0;
	bool reach = 0;
	
	for(int i = 0; i < n; ++i)
	{
	    cin >> p[i];
	    if(i == 0)
	        ps[i] = p[i];
	    else
	        ps[i] = ps[i-1] + p[i];
	    
	    if(!reach)
	        hr += p[i];
	    
	    if(hr < 0)
	    {
	        hr = 0;
	    }
	    
	    if(hr >= h)
	    {
	        cout << "0 " << phs << '\n';
	        reach = 1;
	    }
	    
	    ++phs;
	}
	
	if(reach)
	    return 0;
	
	if(hr == 0)
	{
	    cout << "-1 -1\n";
	    return 0;
	}
	
	day = 1;
	while(!reach)
	{
	    phs = 0;
	    for(int i = 0; i < n; ++i)
	    {
	        hr += p[i];
	        
	        if(hr >= h)
	        {
	            cout << day << " " << phs << '\n';
	            reach = 1;
	            return 0;
	        }
	        
	        if(hr < 0)
	        {
	            hr = 0;
	        }
	        
	        ++phs;
	    }
	    ++day;
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Execution timed out 1088 ms 212 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Execution timed out 1084 ms 468 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Execution timed out 1088 ms 212 KB Time limit exceeded
5 Halted 0 ms 0 KB -