Submission #36243

#TimeUsernameProblemLanguageResultExecution timeMemory
36243touristk2000Money (IZhO17_money)C++14
45 / 100
1500 ms53220 KiB
#include <bits/stdc++.h>
#define inf 1111111
using namespace std;
int n,tom;
int a[inf];
set<int> kom;
int main(){
    //freopen("money.in","r",stdin);
	//freopen("money.out","w",stdout);
    scanf("%d",&n); 
    for(int i =0; i < n; i ++) scanf("%d",a + i);
    kom.insert(inf);
    int i = 0; 
    while(i < n){
        kom.insert(a[i]);
        int up = *kom.upper_bound(a[i]);
        int j = i + 1;
        while(a[j - 1] <= a[j] && a[j] <= up){
            kom.insert(a[j ++]);
        }
        tom ++;
        i = j;
    }
    cout << tom;
    return 0;
}

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:10:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n); 
                   ^
money.cpp:11:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i =0; i < n; i ++) scanf("%d",a + i);
                                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...