Submission #633551

# Submission time Handle Problem Language Result Execution time Memory
633551 2022-08-22T17:40:49 Z BidoTeima Baloni (COCI15_baloni) C++17
100 / 100
758 ms 95988 KB
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS()
{
#ifndef ONLINE_JUDGE
    freopen("output.txt", "w", stdout);
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void moo(string fileName){
    freopen((fileName+".in").c_str(),"r",stdin);
    freopen((fileName+".out").c_str(),"w",stdout);
}
#define tc         \
    int tttttt,subtask;    \
    cin >> tttttt /*>> subtask*/; \
    while (tttttt--)
#define sumrange(l, r, arr) (l == 0 ? arr[r] : arr[r] - arr[l - 1])
#define all(v) v.begin(), v.end()
int main()
{
	int n;
    cin>>n;
    int a[n];
    for(int&i:a)cin>>i;
    reverse(a,a+n);
    set<int>occ[(int)1e6+5];
    for(int i = 0; i < n; i++){
        occ[a[i]].insert(i);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        auto it = occ[a[i] + 1].upper_bound(i);
        if(it == occ[a[i] + 1].end())ans++;
        else occ[a[i] + 1].erase(it);
    }
    cout<<ans;
}	

Compilation message

baloni.cpp: In function 'void ACPLS()':
baloni.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
baloni.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
baloni.cpp: In function 'void moo(std::string)':
baloni.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((fileName+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
baloni.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     freopen((fileName+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 31 ms 47188 KB Output is correct
2 Correct 32 ms 47256 KB Output is correct
3 Correct 33 ms 47440 KB Output is correct
4 Correct 35 ms 47404 KB Output is correct
5 Correct 614 ms 90968 KB Output is correct
6 Correct 758 ms 95988 KB Output is correct
7 Correct 567 ms 87284 KB Output is correct
8 Correct 587 ms 86744 KB Output is correct
9 Correct 636 ms 89352 KB Output is correct
10 Correct 660 ms 90620 KB Output is correct